public function signin() { $email = Request::getParam('email'); $pass = Request::getParam('pass'); $remember = !empty(Request::getParam('remember')); $admin = !empty(Request::getParam('admin')); $user = UserModel::first('email = ?', [$email]); if ($user && Hash::match($pass, $user->pass)) { $permission = PermissionModel::first('user_id = ?', [$user->id])->permission; // check permision type for the user if ($admin && $permission != 'admin') { Session::flash("msg", '<li><span class="msg-error">Error: </span> Ooops!... No admin found (wrong email or password ) , let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); exit; } else { if (!$admin && $permission == 'admin') { Session::flash("msg", '<li><span class="msg-error">Error: </span> Ooops!... No User found (wrong email or password ) , let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); exit; } } $u = new User($user->hash); $u->login($remember); redirect(route('user.profile')); } else { Session::flash("msg", '<li><span class="msg-warning">Warning: </span> Ooops!... wrong email or password, let\'s try one more time!</li>'); Session::flash("data", Request::getALlParams()); goBack(); } }
public static function getData() { return UserModel::first('hash = ?', [self::getHash()]); }