fixed user login

This commit is contained in:
Joshua Perry 2023-01-25 15:36:10 +00:00
parent 1e95a07eec
commit f012f42eeb
1 changed files with 3 additions and 3 deletions

View File

@ -19,8 +19,8 @@ class User {
} }
public function loginSubmit() { public function loginSubmit() {
if ($_POST['username'] == '' && $_POST['password'] = '') { if ($_POST['username'] != '' && $_POST['password'] != '') {
$user = $this->usersTable->find("username", $_POST['username']); $user = $this->usersTable->find("username", $_POST['username'])[0];
if (password_verify($_POST['password'], $user->password)) { if (password_verify($_POST['password'], $user->password)) {
$_SESSION['loggedin'] = $user->id; $_SESSION['loggedin'] = $user->id;
$_SESSION['userType'] = $user->userType; $_SESSION['userType'] = $user->userType;
@ -43,7 +43,7 @@ class User {
$this->vars['response'] .= 'Login Unsuccessful'; $this->vars['response'] .= 'Login Unsuccessful';
} }
return ['template' => 'admin.html.php', return ['template' => 'login.html.php',
'title' => 'Jo\'s Jobs- Login', 'title' => 'Jo\'s Jobs- Login',
'vars' => $this->vars 'vars' => $this->vars
]; ];