예제 #1
0
function GetCurrentUser()
{
    // TODO : use SuperGlobals
    global $currentUser;
    if (isset($currentUser)) {
        return $currentUser;
    }
    if (function_exists('GetIdentityCheckStrategy')) {
        $identityCheckStrategy = GetIdentityCheckStrategy();
        if (isset($identityCheckStrategy)) {
            $storage = new UserIdentityCookieStorage($identityCheckStrategy);
            $userIdentity = $storage->LoadUserIdentity();
            if ($userIdentity != null) {
                if ($identityCheckStrategy->CheckUsernameAndEncryptedPassword($userIdentity->userName, $userIdentity->password)) {
                    $currentUser = $userIdentity->userName;
                    return $currentUser;
                }
            }
        }
    }
    return 'guest';
}
예제 #2
0
 public function ProcessMessages()
 {
     if (isset($_GET[OPERATION_PARAMNAME]) && $_GET[OPERATION_PARAMNAME] == 'logout') {
         $this->ClearUserIdentity();
     } elseif ($this->userIdentityStorage->LoadUserIdentity() != null && !(isset($_POST['username']) && isset($_POST['password']))) {
     } elseif (isset($_POST['username']) && isset($_POST['password'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $saveidentity = isset($_POST['saveidentity']);
         if ($this->CheckUsernameAndPassword($username, $password, $this->errorMessage)) {
             $this->SaveUserIdentity($username, $password, $saveidentity);
             SetCurrentUser($username);
             $this->DoOnAfterLogin($username);
             header('Location: ' . $this->GetUrlToRedirectAfterLogin());
             exit;
         } else {
             $this->lastUserName = $username;
             $this->lastSaveidentity = $saveidentity;
         }
     }
 }
 /**
  * @param string $currentPassword
  * @param string $newPassword
  */
 public function SelfChangePassword($currentPassword, $newPassword)
 {
     $userSelfManagement = new UserSelfManagement($this->app, $this->tableBasedGrantsManager, $this->identityCheckStrategy);
     $userSelfManagement->ValidateAndChangePassword($currentPassword, $newPassword);
     $this->userIdentityStorage->UpdatePassword($newPassword);
 }
예제 #4
0
 public function ClearUserIdentity()
 {
     $this->userIdentityStorage->ClearUserIdentity();
 }