Example #1
0
 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * Returns instanceOf Auth
  *
  * @param  mixed
  * @return void
  */
 function auth()
 {
     return \Stativo\Auth\Auth::instance();
 }