From: ArthurHoaro Date: Fri, 6 May 2016 18:03:10 +0000 (+0200) Subject: Prefill the login field when the authentication has failed X-Git-Tag: v0.7.0~2^2 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=85c4bdc23581b91971315c42508c2d8f7a5fa738 Prefill the login field when the authentication has failed --- diff --git a/index.php b/index.php index 47bae6e8..dd876a66 100644 --- a/index.php +++ b/index.php @@ -495,9 +495,9 @@ if (isset($_POST['login'])) else { ban_loginFailed(); - $redir = ''; + $redir = '&username='. $_POST['login']; if (isset($_GET['post'])) { - $redir = '?post=' . urlencode($_GET['post']); + $redir .= '&post=' . urlencode($_GET['post']); foreach (array('description', 'source', 'title') as $param) { if (!empty($_GET[$param])) { $redir .= '&' . $param . '=' . urlencode($_GET[$param]); @@ -943,6 +943,9 @@ function renderPage() if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. $PAGE->assign('token',$token); + if (isset($_GET['username'])) { + $PAGE->assign('username', escape($_GET['username'])); + } $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); $PAGE->renderPage('loginform'); exit; diff --git a/tpl/loginform.html b/tpl/loginform.html index f0b45df2..a49b42d3 100644 --- a/tpl/loginform.html +++ b/tpl/loginform.html @@ -2,7 +2,13 @@ {include="includes"} +{if="ban_canLogin()"} + {if="empty($username)"} + onload="document.loginform.login.focus();" + {else} + onload="document.loginform.password.focus();" + {/if} +{/if}>