Beispiel #1
0
 public function __construct()
 {
     $auth_flag = true;
     $auth = new HTTP\BasicAuth();
     $auth_params = $auth->getUserPass();
     $user = new \CB\User();
     if (!$user->isLoged()) {
         $auth_flag = false;
         if ($auth_params) {
             $r = $user->Login(strtolower(trim($auth_params[0])), $auth_params[1]);
             if ($r['success'] == true) {
                 $auth_flag = true;
             }
         }
     }
     if (!$auth_flag) {
         $auth->requireLogin();
         die;
     }
 }
Beispiel #2
0
 /**
  * Authenticates the user based on the current request.
  *
  * If authentication is successful, true must be returned.
  * If authentication fails, an exception must be thrown.
  *
  * @param DAV\Server $server
  * @param string $realm
  * @throws DAV\Exception\NotAuthenticated
  * @return bool
  */
 public function authenticate(DAV\Server $server, $realm)
 {
     $auth = new HTTP\BasicAuth();
     $auth->setHTTPRequest($server->httpRequest);
     $auth->setHTTPResponse($server->httpResponse);
     $auth->setRealm($realm);
     $userpass = $auth->getUserPass();
     if (!$userpass) {
         $auth->requireLogin();
         throw new DAV\Exception\NotAuthenticated('No basic authentication headers were found');
     }
     // Authenticates the user
     if (!$this->validateUserPass($userpass[0], $userpass[1])) {
         $auth->requireLogin();
         throw new DAV\Exception\NotAuthenticated('Username or password does not match');
     }
     $this->currentUser = $userpass[0];
     return true;
 }