Exemplo n.º 1
0
 /**
  * After a successful login attempt, registers the user in the session.
  * @param  int $uid The User account's ID.
  * @return null
  * @throws  \Directus\Auth\UserAlreadyLoggedInException
  */
 private static function completeLogin($uid)
 {
     self::prependSessionKey();
     if (self::loggedIn()) {
         throw new UserAlreadyLoggedInException(__t('attempting_to_authenticate_a_user_when_a_user_is_already_authenticated'));
     }
     $user = ['id' => $uid, 'access_token' => sha1($uid . StringUtils::randomString())];
     $_SESSION[self::$SESSION_KEY] = $user;
     self::$authenticated = true;
 }
Exemplo n.º 2
0
 public static function setUserCacheRefreshProvider($callable)
 {
     self::prependSessionKey();
     if (!is_callable($callable)) {
         throw new \InvalidArgumentException("Argument must be callable");
     }
     self::$userCacheRefreshProvider = $callable;
 }