From f3e04e4193afaebf392beb1d5d7c547c495ddf62 Mon Sep 17 00:00:00 2001 From: Partydragen Date: Tue, 13 Sep 2022 00:33:16 +0200 Subject: [PATCH] Remove user field from re-auth page (#3071) --- custom/panel_templates/Default/auth.tpl | 13 ----- modules/Core/pages/panel/auth.php | 71 +++---------------------- 2 files changed, 6 insertions(+), 78 deletions(-) diff --git a/custom/panel_templates/Default/auth.tpl b/custom/panel_templates/Default/auth.tpl index 5c66d54400..85726147cc 100644 --- a/custom/panel_templates/Default/auth.tpl +++ b/custom/panel_templates/Default/auth.tpl @@ -17,19 +17,6 @@ {/if}
- {if isset($EMAIL)} -
- -
- {else} -
- -
- {/if}
diff --git a/modules/Core/pages/panel/auth.php b/modules/Core/pages/panel/auth.php index 6f55eca86e..00656ef3a2 100644 --- a/modules/Core/pages/panel/auth.php +++ b/modules/Core/pages/panel/auth.php @@ -2,7 +2,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr12 + * NamelessMC version 2.0.2 * * License: MIT * @@ -28,60 +28,20 @@ $page_title = $language->get('admin', 're-authenticate'); require_once(ROOT_PATH . '/core/templates/backend_init.php'); -// Get login method -$login_method = DB::getInstance()->get('settings', ['name', 'login_method'])->results(); -$login_method = $login_method[0]->value; - // Deal with any input if (Input::exists()) { if (Token::check()) { // Validate input - if ($login_method == 'email') { - $to_validate = [ - 'email' => [ - Validate::REQUIRED => true, - Validate::IS_BANNED => true, - Validate::IS_ACTIVE => true - ], - 'password' => [ - Validate::REQUIRED => true - ] - ]; - } else { - $to_validate = [ - 'username' => [ - Validate::REQUIRED => true, - Validate::IS_BANNED => true, - Validate::IS_ACTIVE => true - ], - 'password' => [ + $validation = Validate::check($_POST, [ + 'password' => [ Validate::REQUIRED => true ] - ]; - } - - $validation = Validate::check($_POST, $to_validate); + ] + ); if ($validation->passed()) { - if ($login_method == 'email') { - $username = Input::get('email'); - $method_field = 'email'; - } else { - if ($login_method == 'email_or_username') { - $username = Input::get('username'); - if (str_contains(Input::get('username'), '@')) { - $method_field = 'email'; - } else { - $method_field = 'username'; - } - } else { - $username = Input::get('username'); - $method_field = 'username'; - } - } - $user = new User(); - $login = $user->adminLogin($username, Input::get('password'), $method_field); + $login = $user->adminLogin($user->data()->email, Input::get('password'), 'email'); if ($login) { // Get IP @@ -108,25 +68,6 @@ } } -if ($login_method == 'email') { - $smarty->assign([ - 'EMAIL' => $language->get('user', 'email'), - 'EMAIL_VALUE' => Output::getClean(Input::get('email')), - ]); -} else { - if ($login_method == 'email_or_username') { - $smarty->assign([ - 'USERNAME' => $language->get('user', 'email_or_username'), - 'USERNAME_VALUE' => Output::getClean(Input::get('username')), - ]); - } else { - $smarty->assign([ - 'USERNAME' => $language->get('user', 'username'), - 'USERNAME_VALUE' => Output::getClean(Input::get('username')), - ]); - } -} - $smarty->assign([ 'PLEASE_REAUTHENTICATE' => $language->get('admin', 're-authenticate'), 'PASSWORD' => $language->get('user', 'password'),