Changed login process
This commit is contained in:
parent
ab8506882a
commit
8eb9005642
@ -85,11 +85,21 @@ class Home
|
|||||||
|
|
||||||
public function put($args = [])
|
public function put($args = [])
|
||||||
{
|
{
|
||||||
if ($this->access->login($args)) {
|
if ($user = $this->access->login($args)) {
|
||||||
|
Session::put('userid', $user['id']);
|
||||||
|
Session::put('username', $user['username']);
|
||||||
|
Session::put('full_name', $user['full_name']);
|
||||||
|
Session::put('privilage', $user['privilage']);
|
||||||
|
|
||||||
$table = 'user';
|
$table = 'user';
|
||||||
$id = Session::get('userid');
|
$id = Session::get('userid');
|
||||||
|
|
||||||
$this->access->update($table, ['status' => 1], $id);
|
if ($this->access->update($table, ['status' => 1], $id)) {
|
||||||
|
$username = Session::get('username');
|
||||||
|
Session::flash('info', "$username logged in");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('info', 'Invalid username/password');
|
||||||
}
|
}
|
||||||
Redirect::to('/');
|
Redirect::to('/');
|
||||||
}
|
}
|
||||||
|
@ -83,20 +83,11 @@ class Access extends \Core\Model
|
|||||||
if (\Core\Hash::compare($password, $salt, $hash)) {
|
if (\Core\Hash::compare($password, $salt, $hash)) {
|
||||||
$user = $this->showSingle($id);
|
$user = $this->showSingle($id);
|
||||||
|
|
||||||
\Core\Session::put('userid', $user['id']);
|
return $user;
|
||||||
\Core\Session::put('username', $user['username']);
|
}
|
||||||
\Core\Session::put('full_name', $user['full_name']);
|
return false;
|
||||||
\Core\Session::put('privilage', $user['privilage']);
|
|
||||||
|
|
||||||
$user_now = $user['username'];
|
|
||||||
|
|
||||||
\Core\Session::flash('info', "$user_now logged in");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
\Core\Session::flash('info', 'Invalid username/password');
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
throw new \Exception($e->getMessage(), 444);
|
throw new \Exception($e->getMessage(), 444);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user