Compare commits
3 commits
8d0907b1ba
...
ff9f623f99
Author | SHA1 | Date | |
---|---|---|---|
|
ff9f623f99 | ||
|
15c1daabb5 | ||
|
43a467b15a |
9 changed files with 80 additions and 18 deletions
|
@ -24,7 +24,7 @@
|
|||
"smarty-gettext/smarty-gettext": "^1.6",
|
||||
"sepia/po-parser": "^6.0",
|
||||
"sentry/sdk": "^3.3",
|
||||
"ext-pdo": "^7.3",
|
||||
"ext-pdo": ">=7.3",
|
||||
"ext-json": "*",
|
||||
"ext-yaml": "^2.0",
|
||||
"league/mime-type-detection": "^1.11",
|
||||
|
|
|
@ -172,6 +172,12 @@ auth:
|
|||
http: "HTTP"
|
||||
cas: "SSO"
|
||||
|
||||
# Remember username
|
||||
# Enable the feature (default: true)
|
||||
# remember_username: true
|
||||
# Cookie name (default: remember_username)
|
||||
# remember_username_cookie_name: "remember_username"
|
||||
|
||||
#
|
||||
# HTTP Authentication Configuration
|
||||
#
|
||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2023-03-22 19:13+0100\n"
|
||||
"POT-Creation-Date: 2023-04-22 18:48+0200\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: Benjamin Renard <brenard@easter-eggs.com>\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -28,11 +28,11 @@ msgstr "Inconnu"
|
|||
msgid "Unable to connect to the database."
|
||||
msgstr "Impossible de se connecter à la base de données."
|
||||
|
||||
#: Auth/Form.php:41
|
||||
#: Auth/Form.php:51
|
||||
msgid "Invalid username or password."
|
||||
msgstr "Nom d'utilisateur ou mot de passe invalide."
|
||||
|
||||
#: Auth/Form.php:74
|
||||
#: Auth/Form.php:92
|
||||
msgid "Sign in"
|
||||
msgstr "Connexion"
|
||||
|
||||
|
@ -581,15 +581,19 @@ msgstr "Merci de patienter pendant le traitement de votre requête."
|
|||
msgid "Are you sure?"
|
||||
msgstr "Êtes-vous sure ?"
|
||||
|
||||
#: templates/login.tpl:19 templates/login.tpl:20
|
||||
#: templates/login.tpl:20 templates/login.tpl:21
|
||||
msgid "Username"
|
||||
msgstr "Nom d'utilisateur"
|
||||
|
||||
#: templates/login.tpl:24 templates/login.tpl:25
|
||||
#: templates/login.tpl:26 templates/login.tpl:27
|
||||
msgid "Password"
|
||||
msgstr "Mot de passe"
|
||||
|
||||
#: templates/login.tpl:29
|
||||
#: templates/login.tpl:33
|
||||
msgid "Remember username"
|
||||
msgstr "Mémoriser nom d'utilisateur"
|
||||
|
||||
#: templates/login.tpl:38
|
||||
msgid "Submit"
|
||||
msgstr "Envoyer"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"POT-Creation-Date: 2023-03-22 19:13+0100\n"
|
||||
"PO-Revision-Date: 2023-03-22 19:13+0100\n"
|
||||
"POT-Creation-Date: 2023-04-22 18:48+0200\n"
|
||||
"PO-Revision-Date: 2023-04-22 18:48+0200\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
@ -22,11 +22,11 @@ msgstr ""
|
|||
msgid "Unable to connect to the database."
|
||||
msgstr ""
|
||||
|
||||
#: Auth/Form.php:41
|
||||
#: Auth/Form.php:51
|
||||
msgid "Invalid username or password."
|
||||
msgstr ""
|
||||
|
||||
#: Auth/Form.php:74
|
||||
#: Auth/Form.php:92
|
||||
msgid "Sign in"
|
||||
msgstr ""
|
||||
|
||||
|
@ -504,15 +504,19 @@ msgstr ""
|
|||
msgid "Are you sure?"
|
||||
msgstr ""
|
||||
|
||||
#: templates/login.tpl:19 templates/login.tpl:20
|
||||
#: templates/login.tpl:20 templates/login.tpl:21
|
||||
msgid "Username"
|
||||
msgstr ""
|
||||
|
||||
#: templates/login.tpl:24 templates/login.tpl:25
|
||||
#: templates/login.tpl:26 templates/login.tpl:27
|
||||
msgid "Password"
|
||||
msgstr ""
|
||||
|
||||
#: templates/login.tpl:29
|
||||
#: templates/login.tpl:33
|
||||
msgid "Remember username"
|
||||
msgstr ""
|
||||
|
||||
#: templates/login.tpl:38
|
||||
msgid "Submit"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -172,6 +172,12 @@ auth:
|
|||
http: "HTTP"
|
||||
cas: "SSO"
|
||||
|
||||
# Remember username
|
||||
# Enable the feature (default: true)
|
||||
# remember_username: true
|
||||
# Cookie name (default: remember_username)
|
||||
# remember_username_cookie_name: "remember_username"
|
||||
|
||||
#
|
||||
# HTTP Authentication Configuration
|
||||
#
|
||||
|
|
|
@ -22,6 +22,8 @@ class Form extends Method {
|
|||
array(
|
||||
'display_other_methods' => array(),
|
||||
'include_navbar' => true,
|
||||
'remember_username' => true,
|
||||
'remember_username_cookie_name' => 'remember_username',
|
||||
)
|
||||
);
|
||||
Url :: add_url_handler('#^login$#', array('EesyPHP\\Auth\\Form', 'handle_login'), null, false);
|
||||
|
@ -38,7 +40,15 @@ class Form extends Method {
|
|||
$user = null;
|
||||
if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
|
||||
$user = Auth :: authenticate($_REQUEST['username'], $_REQUEST['password']);
|
||||
if (!$user) Tpl::add_error(_('Invalid username or password.'));
|
||||
if ($user) {
|
||||
setcookie(
|
||||
App::get('auth.login_form.remember_username_cookie_name'),
|
||||
App::get('auth.login_form.remember_username') && isset($_REQUEST['remember-username'])?
|
||||
$user->username:null
|
||||
);
|
||||
}
|
||||
else
|
||||
Tpl::add_error(_('Invalid username or password.'));
|
||||
}
|
||||
if ($force && !$user) {
|
||||
if (Url :: get_current_url() != 'login')
|
||||
|
@ -67,8 +77,15 @@ class Form extends Method {
|
|||
}
|
||||
if ($user)
|
||||
Url :: redirect(isset($_REQUEST['next'])?urldecode($_REQUEST['next']):null);
|
||||
else
|
||||
Tpl :: assign('next', (isset($_REQUEST['next'])?urldecode($_REQUEST['next']):''));
|
||||
|
||||
$remember_username = App::get('auth.login_form.remember_username', null, 'bool');
|
||||
Tpl :: assign('remember_username', $remember_username);
|
||||
if ($remember_username) {
|
||||
$cookie_name = App::get('auth.login_form.remember_username_cookie_name');
|
||||
Tpl :: assign('username', isset($_COOKIE[$cookie_name])?$_COOKIE[$cookie_name]:null);
|
||||
}
|
||||
|
||||
Tpl :: assign('next', isset($_REQUEST['next'])?urldecode($_REQUEST['next']):'');
|
||||
Tpl :: assign('display_other_methods', $display_other_methods);
|
||||
Tpl :: assign('include_navbar', App::get('auth.login_form.include_navbar', null, 'bool'));
|
||||
Tpl :: display('login.tpl', I18n::_('Sign in'));
|
||||
|
|
|
@ -328,4 +328,20 @@ function format_duration($value, $unit=null, $precision=null, $separator=null) {
|
|||
return implode(is_null($separator)?' ':strval($separator), $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implode array's keys & values (ex: 'k1=v1, k2=v2, ...')
|
||||
* @param array<string|int,mixed> $values Array to implode
|
||||
* @param boolean $quoted Set to false to disable values quotting (optional, default: true)
|
||||
* @param string $separator Values separator (opional, default: ", ")
|
||||
* @param string $kv_separator Key/value separator (optional, default: "=")
|
||||
* @return string Imploded array string
|
||||
*/
|
||||
function implode_with_keys($values, $quoted=true, $separator=', ', $kv_separator='=') {
|
||||
$result = [];
|
||||
$quoted = $quoted?'"':'';
|
||||
foreach ($values as $key => $value)
|
||||
$result[] = "$key$kv_separator$quoted$value$quoted";
|
||||
return implode($separator, $result);
|
||||
}
|
||||
|
||||
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" id="input_username" name="username"
|
||||
placeholder="{t domain=$CORE_TEXT_DOMAIN}Username{/t}"/>
|
||||
placeholder="{t domain=$CORE_TEXT_DOMAIN}Username{/t}" value="{if $remember_username && $username}{$username|escape:"quotes"}{/if}"/>
|
||||
<label for="input_username">{t domain=$CORE_TEXT_DOMAIN}Username{/t}</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
|
@ -25,6 +25,15 @@
|
|||
<label for="input_password">{t domain=$CORE_TEXT_DOMAIN}Password{/t}</label>
|
||||
</div>
|
||||
|
||||
{if $remember_username}
|
||||
<div class="checkbox mb-3">
|
||||
<label>
|
||||
<input type="checkbox" name="remember-username" value="remember" {if $username}checked{/if}>
|
||||
{t domain=$CORE_TEXT_DOMAIN}Remember username{/t}
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<button class="w-100 btn btn-lg btn-primary" type="submit">
|
||||
{t domain=$CORE_TEXT_DOMAIN}Submit{/t}
|
||||
</button>
|
||||
|
|
Loading…
Reference in a new issue