Compare commits

..

No commits in common. "ff9f623f99addb1f77da6f63d3f529a958b13c28" and "8d0907b1ba46f0afc50d939bef0720977b64d3bc" have entirely different histories.

9 changed files with 18 additions and 80 deletions

View file

@ -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",

View file

@ -172,12 +172,6 @@ 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
#

View file

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2023-04-22 18:48+0200\n"
"POT-Creation-Date: 2023-03-22 19:13+0100\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:51
#: Auth/Form.php:41
msgid "Invalid username or password."
msgstr "Nom d'utilisateur ou mot de passe invalide."
#: Auth/Form.php:92
#: Auth/Form.php:74
msgid "Sign in"
msgstr "Connexion"
@ -581,19 +581,15 @@ msgstr "Merci de patienter pendant le traitement de votre requête."
msgid "Are you sure?"
msgstr "Êtes-vous sure ?"
#: templates/login.tpl:20 templates/login.tpl:21
#: templates/login.tpl:19 templates/login.tpl:20
msgid "Username"
msgstr "Nom d'utilisateur"
#: templates/login.tpl:26 templates/login.tpl:27
#: templates/login.tpl:24 templates/login.tpl:25
msgid "Password"
msgstr "Mot de passe"
#: templates/login.tpl:33
msgid "Remember username"
msgstr "Mémoriser nom d'utilisateur"
#: templates/login.tpl:38
#: templates/login.tpl:29
msgid "Submit"
msgstr "Envoyer"

View file

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"POT-Creation-Date: 2023-04-22 18:48+0200\n"
"PO-Revision-Date: 2023-04-22 18:48+0200\n"
"POT-Creation-Date: 2023-03-22 19:13+0100\n"
"PO-Revision-Date: 2023-03-22 19:13+0100\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:51
#: Auth/Form.php:41
msgid "Invalid username or password."
msgstr ""
#: Auth/Form.php:92
#: Auth/Form.php:74
msgid "Sign in"
msgstr ""
@ -504,19 +504,15 @@ msgstr ""
msgid "Are you sure?"
msgstr ""
#: templates/login.tpl:20 templates/login.tpl:21
#: templates/login.tpl:19 templates/login.tpl:20
msgid "Username"
msgstr ""
#: templates/login.tpl:26 templates/login.tpl:27
#: templates/login.tpl:24 templates/login.tpl:25
msgid "Password"
msgstr ""
#: templates/login.tpl:33
msgid "Remember username"
msgstr ""
#: templates/login.tpl:38
#: templates/login.tpl:29
msgid "Submit"
msgstr ""

View file

@ -172,12 +172,6 @@ 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
#

View file

@ -22,8 +22,6 @@ 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);
@ -40,15 +38,7 @@ class Form extends Method {
$user = null;
if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
$user = Auth :: authenticate($_REQUEST['username'], $_REQUEST['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 (!$user) Tpl::add_error(_('Invalid username or password.'));
}
if ($force && !$user) {
if (Url :: get_current_url() != 'login')
@ -77,15 +67,8 @@ class Form extends Method {
}
if ($user)
Url :: redirect(isset($_REQUEST['next'])?urldecode($_REQUEST['next']):null);
$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']):'');
else
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'));

View file

@ -328,20 +328,4 @@ 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

View file

@ -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}" value="{if $remember_username && $username}{$username|escape:"quotes"}{/if}"/>
placeholder="{t domain=$CORE_TEXT_DOMAIN}Username{/t}"/>
<label for="input_username">{t domain=$CORE_TEXT_DOMAIN}Username{/t}</label>
</div>
<div class="form-floating">
@ -25,15 +25,6 @@
<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>