コード例 #1
0
ファイル: TestUser.php プロジェクト: ptphp/ptphp
 function __construct()
 {
     \Model_Admin_Auth::set_login_session(-1);
     $this->obj = new User();
 }
コード例 #2
0
ファイル: auth.php プロジェクト: ptphp/ptphp
 static function login_safe($username, $password, $safe_token)
 {
     if (!$safe_token && PtConfig::$userRsaAuth) {
         _throw("safe_token is null");
     }
     if (!$username) {
         _throw("username is null");
     }
     if (!$password) {
         _throw("password is null");
     }
     if (PtConfig::$userRsaAuth) {
         $encrypt_data = self::_redis()->get(self::ENCRYPT_CACEH_KEY . $safe_token);
         if (empty($encrypt_data)) {
             _throw("加密信息已过期");
         }
         $encrypt_data = json_decode($encrypt_data);
         $private_key = $encrypt_data->private_key;
         $req = array('username' => $username, 'password' => $password);
         $req = Safe::decrypt($req, $private_key);
         //self::_debug($req);
         if (!$req) {
             _throw("解密失败");
         }
         $username = $req['username'];
         $password = $req['password'];
     }
     if (self::__check_safe_login($username, $password)) {
         Model_Admin_Auth::set_login_session(-1);
     } elseif ($user_id = self::__check_admin_login($username, $password)) {
         Model_Admin_Auth::set_login_session($user_id);
     } else {
         _throw("用户和密码不正确");
     }
     return true;
 }