Example #1
0
 /**
  * Save the User.
  *
  * @param  Blog\Models\User $user
  * @param  Array  $inputs
  * @return void
  */
 private function save($user, $inputs)
 {
     if (isset($inputs['seen'])) {
         $user->seen = $inputs['seen'] == 'true';
     } else {
         $user->username = $inputs['username'];
         $user->email = $inputs['email'];
         if (isset($inputs['confirmation_code'])) {
             $user->confirmation_code = $inputs['confirmation_code'];
         }
         if (isset($inputs['role'])) {
             $user->role_id = $inputs['role'];
         } else {
             $role_user = $this->role->where('slug', 'user')->first();
             $user->role_id = $role_user->id;
         }
     }
     $user->save();
 }
Example #2
0
 protected function checkRememberMe()
 {
     if ($this->app->getCookie($this->app->config->get('auth.remember')) && !$this->app->auth) {
         $data = $this->app->getCookie($this->app->config->get('auth.remember'));
         $credentials = explode('___', $data);
         if (empty(trim($data)) || count($credentials) !== 2) {
             $this->app->redirect('/');
         } else {
             $identifier = $credentials[0];
             $token = $this->app->hash->hash($credentials[1]);
             $user = User::where('remember_identifier', $identifier)->first();
             if ($user) {
                 if ($this->app->hash->hashCheck($token, $user->remember_token)) {
                     $_SESSION[$this->app->config->get('auth.session')] = $user->id;
                     $this->app->auth = User::where('id', $user->id)->first();
                 } else {
                     $user->removeRememberCredentials();
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Destroy a user.
  *
  * @param  Blog\Models\User $user
  * @return void
  */
 public function destroyUser(User $user)
 {
     $user->comments()->delete();
     $user->delete();
 }
Example #4
0
 private function findUser($usernma, $email)
 {
     return Models\User::find(array('search' => 'user or email', 'values' => array($username, $email)));
 }