Skip to content

Commit

Permalink
Remove user field from re-auth page (#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
partydragen authored and tadhgboyle committed Oct 15, 2022
1 parent e17724c commit f3e04e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 78 deletions.
13 changes: 0 additions & 13 deletions custom/panel_templates/Default/auth.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@
</div>
{/if}
<form class="user" action="" method="post">
{if isset($EMAIL)}
<div class="form-group has-feedback">
<input type="email" name="email" id="email" autocomplete="off"
class="form-control form-control-user" placeholder="{$EMAIL}"
value="{$EMAIL_VALUE}">
</div>
{else}
<div class="form-group has-feedback">
<input type="text" name="username" id="username" autocomplete="off"
class="form-control form-control-user" placeholder="{$USERNAME}"
value="{$USERNAME_VALUE}">
</div>
{/if}
<div class="form-group has-feedback">
<input type="password" name="password" id="password"
class="form-control form-control-user" placeholder="{$PASSWORD}">
Expand Down
71 changes: 6 additions & 65 deletions modules/Core/pages/panel/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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
Expand All @@ -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'),
Expand Down

0 comments on commit f3e04e4

Please sign in to comment.