diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-05-06 20:03:10 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-05-06 20:03:10 +0200 |
commit | 85c4bdc23581b91971315c42508c2d8f7a5fa738 (patch) | |
tree | ae7aa68711121ca2aef144088686c62aa2167769 | |
parent | dbcd06e988d8434f125b8a5ee8f5bbcb7cd87874 (diff) | |
download | Shaarli-85c4bdc23581b91971315c42508c2d8f7a5fa738.tar.gz Shaarli-85c4bdc23581b91971315c42508c2d8f7a5fa738.tar.zst Shaarli-85c4bdc23581b91971315c42508c2d8f7a5fa738.zip |
Prefill the login field when the authentication has failed
-rw-r--r-- | index.php | 7 | ||||
-rw-r--r-- | tpl/loginform.html | 15 |
2 files changed, 17 insertions, 5 deletions
@@ -495,9 +495,9 @@ if (isset($_POST['login'])) | |||
495 | else | 495 | else |
496 | { | 496 | { |
497 | ban_loginFailed(); | 497 | ban_loginFailed(); |
498 | $redir = ''; | 498 | $redir = '&username='. $_POST['login']; |
499 | if (isset($_GET['post'])) { | 499 | if (isset($_GET['post'])) { |
500 | $redir = '?post=' . urlencode($_GET['post']); | 500 | $redir .= '&post=' . urlencode($_GET['post']); |
501 | foreach (array('description', 'source', 'title') as $param) { | 501 | foreach (array('description', 'source', 'title') as $param) { |
502 | if (!empty($_GET[$param])) { | 502 | if (!empty($_GET[$param])) { |
503 | $redir .= '&' . $param . '=' . urlencode($_GET[$param]); | 503 | $redir .= '&' . $param . '=' . urlencode($_GET[$param]); |
@@ -943,6 +943,9 @@ function renderPage() | |||
943 | if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli | 943 | if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli |
944 | $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. | 944 | $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. |
945 | $PAGE->assign('token',$token); | 945 | $PAGE->assign('token',$token); |
946 | if (isset($_GET['username'])) { | ||
947 | $PAGE->assign('username', escape($_GET['username'])); | ||
948 | } | ||
946 | $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); | 949 | $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); |
947 | $PAGE->renderPage('loginform'); | 950 | $PAGE->renderPage('loginform'); |
948 | exit; | 951 | 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 @@ | |||
2 | <html> | 2 | <html> |
3 | <head>{include="includes"}</head> | 3 | <head>{include="includes"}</head> |
4 | <body | 4 | <body |
5 | {if="ban_canLogin()"} onload="document.loginform.login.focus();"{/if}> | 5 | {if="ban_canLogin()"} |
6 | {if="empty($username)"} | ||
7 | onload="document.loginform.login.focus();" | ||
8 | {else} | ||
9 | onload="document.loginform.password.focus();" | ||
10 | {/if} | ||
11 | {/if}> | ||
6 | <div id="pageheader"> | 12 | <div id="pageheader"> |
7 | {include="page.header"} | 13 | {include="page.header"} |
8 | 14 | ||
@@ -11,8 +17,11 @@ | |||
11 | You have been banned from login after too many failed attempts. Try later. | 17 | You have been banned from login after too many failed attempts. Try later. |
12 | {else} | 18 | {else} |
13 | <form method="post" name="loginform"> | 19 | <form method="post" name="loginform"> |
14 | <label for="login">Login: <input type="text" id="login" name="login" tabindex="1"></label> | 20 | <label for="login">Login: <input type="text" id="login" name="login" tabindex="1" |
15 | <label for="password">Password: <input type="password" id="password" name="password" tabindex="2"></label> | 21 | {if="!empty($username)"}value="{$username}"{/if}> |
22 | </label> | ||
23 | <label for="password">Password: <input type="password" id="password" name="password" tabindex="2"> | ||
24 | </label> | ||
16 | <input type="submit" value="Login" class="bigbutton" tabindex="4"> | 25 | <input type="submit" value="Login" class="bigbutton" tabindex="4"> |
17 | <label for="longlastingsession"> | 26 | <label for="longlastingsession"> |
18 | <input type="checkbox" name="longlastingsession" id="longlastingsession" tabindex="3"> | 27 | <input type="checkbox" name="longlastingsession" id="longlastingsession" tabindex="3"> |