diff options
author | Arthur <arthur@hoa.ro> | 2016-05-14 11:09:39 +0200 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2016-05-14 11:09:39 +0200 |
commit | 52ccf0d7ee25eb0b6fc405aafcf7211ef07307e1 (patch) | |
tree | 404379a9cea49201b3950de88c6f731a24349bb0 | |
parent | 765391cb376500a8372aedd426dd4bfbe04ee8ec (diff) | |
parent | 85c4bdc23581b91971315c42508c2d8f7a5fa738 (diff) | |
download | Shaarli-52ccf0d7ee25eb0b6fc405aafcf7211ef07307e1.tar.gz Shaarli-52ccf0d7ee25eb0b6fc405aafcf7211ef07307e1.tar.zst Shaarli-52ccf0d7ee25eb0b6fc405aafcf7211ef07307e1.zip |
Merge pull request #556 from ArthurHoaro/login-refill
Prefill the login field when the authentication has failed
-rw-r--r-- | index.php | 7 | ||||
-rw-r--r-- | tpl/loginform.html | 46 |
2 files changed, 33 insertions, 20 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 678375fd..a49b42d3 100644 --- a/tpl/loginform.html +++ b/tpl/loginform.html | |||
@@ -1,26 +1,36 @@ | |||
1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
2 | <html> | 2 | <html> |
3 | <head>{include="includes"}</head> | 3 | <head>{include="includes"}</head> |
4 | <body{if="ban_canLogin()"} onload="document.loginform.login.focus();"{/if}> | 4 | <body |
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}> | ||
5 | <div id="pageheader"> | 12 | <div id="pageheader"> |
6 | {include="page.header"} | 13 | {include="page.header"} |
7 | 14 | ||
8 | <div id="headerform"> | 15 | <div id="headerform"> |
9 | {if="!ban_canLogin()"} | 16 | {if="!ban_canLogin()"} |
10 | 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. |
11 | {else} | 18 | {else} |
12 | <form method="post" name="loginform"> | 19 | <form method="post" name="loginform"> |
13 | <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" |
14 | <label for="password">Password: <input type="password" id="password" name="password" tabindex="2"></label> | 21 | {if="!empty($username)"}value="{$username}"{/if}> |
15 | <input type="submit" value="Login" class="bigbutton" tabindex="4"> | 22 | </label> |
16 | <label for="longlastingsession"> | 23 | <label for="password">Password: <input type="password" id="password" name="password" tabindex="2"> |
17 | <input type="checkbox" name="longlastingsession" id="longlastingsession" tabindex="3"> | 24 | </label> |
18 | Stay signed in (Do not check on public computers)</label> | 25 | <input type="submit" value="Login" class="bigbutton" tabindex="4"> |
19 | <input type="hidden" name="token" value="{$token}"> | 26 | <label for="longlastingsession"> |
20 | {if="$returnurl"}<input type="hidden" name="returnurl" value="{$returnurl}">{/if} | 27 | <input type="checkbox" name="longlastingsession" id="longlastingsession" tabindex="3"> |
21 | </form> | 28 | Stay signed in (Do not check on public computers)</label> |
22 | {/if} | 29 | <input type="hidden" name="token" value="{$token}"> |
23 | </div> | 30 | {if="$returnurl"}<input type="hidden" name="returnurl" value="{$returnurl}">{/if} |
31 | </form> | ||
32 | {/if} | ||
33 | </div> | ||
24 | </div> | 34 | </div> |
25 | 35 | ||
26 | {include="page.footer"} | 36 | {include="page.footer"} |