public function run(Request $request, Response $response) { if (!($user = Auth::instance()->logged_in())) { // This is an example middleware for the authentication class // Return to login page or something } else { Auth::$user = $user; } // Keep in mind that middlewares need to return an instance of Middleware ($this) return $this; }
/** * Set new password to user * @param string $password the new password * @param integer $user_id [Optional] if is set, update that user else update current logged in user */ public function setPassword($password, $user_id = null) { if ($user_id !== null) { $user = $this->_userModel->find($user_id); } else { $user = Auth::instance()->user(); } $user->password = password_hash($password, $this->_config['algorithm']); return $user; }
/** * Returns instanceOf Auth * * @param mixed * @return void */ function auth() { return \Stativo\Auth\Auth::instance(); }