示例#1
0
文件: CCAuth.php 项目: clancats/core
 /**
  * prepare the configuration
  *
  * @return void
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     CCConfig::create('auth')->_data = CCConfig::create('Core::phpunit/auth')->_data;
     $user = new Auth\User();
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->save();
     static::$current_user = $user;
 }
示例#2
0
 /**
  * Get's either the currently logged in user or the specified user by id or Login
  * Column value.
  *
  * @param   int|string  User id or Login Column value to find.
  * @throws  SentryException
  * @return  Sentry_User
  */
 public static function user($id = null, $recache = false)
 {
     if ($id === null and $recache === false and static::$current_user !== null) {
         return static::$current_user;
     } elseif ($id !== null and $recache === false and isset(static::$user_cache[$id])) {
         return static::$user_cache[$id];
     }
     try {
         if ($id) {
             static::$user_cache[$id] = new Sentry_User($id);
             return static::$user_cache[$id];
         } elseif (static::check()) {
             $user_id = Session::get(Config::get('sentry::sentry.session.user'));
             static::$current_user = new Sentry_User($user_id);
             return static::$current_user;
         }
         // else return empty user
         return new Sentry_User();
     } catch (SentryUserException $e) {
         throw new SentryException($e->getMessage());
     }
 }
示例#3
0
 /**
  * Imposta l'utente connesso attualmente (se disponibile)
  * @param ModelUser $identifier  
  */
 public static function setCurrentUser($user){
     if(static::$current_user != null) return;
     static::$current_user = $user;
 }
 /**
  * save the current user id in the session.
  *
  * @param $user
  *   a User object. The client is considered logged in as
  *   <code>$user</code> when this function return. if NULL, the current
  *   user is "logged out", meaning the session user id is unset.
  */
 public static function current_is($user)
 {
     if (is_null($user)) {
         static::$current_user = NULL;
         if (session_active()) {
             unset($_SESSION['uid']);
         }
     } else {
         if ($user instanceof static) {
             static::$current_user = $user;
             if (session_active()) {
                 $_SESSION['uid'] = $user->id;
             }
         } else {
             No2_Logger::err(get_called_class() . 'current_is: ' . 'Wrong user type: ' . get_class($user));
         }
     }
 }
示例#5
0
 /**
  * Master function to evaluate current user's login-ish-ness.
  */
 public static function evaluateSession()
 {
     if (!static::isLoggedIn()) {
         return;
     }
     static::$logged_in = true;
     static::$current_user = fAuthorization::getUserToken();
 }