public function addUserAction(IOpenIdUser $user, $ip, $user_action, $realm = null)
 {
     try {
         $action = new UserAction();
         $action->from_ip = $ip;
         $action->user_action = $user_action;
         $action->realm = $realm;
         $user = User::find($user->getId());
         if ($user) {
             $user->actions()->save($action);
             return true;
         }
         return false;
     } catch (Exception $ex) {
         Log::error($ex);
         return false;
     }
 }
Beispiel #2
0
 /**
  * @return bool
  * @throws \Auth\AuthException
  */
 public function loginSocial()
 {
     if (!$this->session->token) {
         if (isset($_POST['token']) && isset($_SERVER['HTTP_HOST'])) {
             $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
             $result = json_decode($s, true);
             $userProviders = UserProviders::find(['uid' => $result['uid']])[0];
             $auth = new A();
             $auth->user_id = $userProviders->user_id;
             $auth->provider_id = $userProviders->provider_id;
             $auth->token = uniqid();
             $auth->save();
             $this->session->token = $auth->token;
             $this->session->user = User::find(['id' => $auth->user_id])[0];
             return true;
         }
     } else {
         throw new AuthException('You are already logged in!');
     }
 }
Beispiel #3
0
 public function getUserById($id)
 {
     return User::find($id);
 }