Exemplo n.º 1
0
 public function generateSVNTokenForUser(PFUser $user, $comment)
 {
     $token = $this->generateRandomToken();
     $token_computed = $this->password_handler->computeUnixPassword($token);
     if ($this->token_dao->generateSVNTokenForUser($user->getId(), $token_computed, $comment)) {
         return $token;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 function updateByRow(array $user)
 {
     $stmt = array();
     if (isset($user['clear_password'])) {
         $stmt[] = 'password='******'clear_password']));
         if (ForgeConfig::get('sys_keep_md5_hashed_password')) {
             $stmt[] = 'user_pw=' . $this->da->quoteSmart(md5($user['clear_password']));
         } else {
             $stmt[] = 'user_pw=""';
         }
         $stmt[] = 'unix_pw=' . $this->da->quoteSmart($this->password_handler->computeUnixPassword($user['clear_password']));
         $stmt[] = 'last_pwd_update=' . $_SERVER['REQUEST_TIME'];
         unset($user['clear_password']);
     }
     $dar = $this->searchByUserId($user['user_id']);
     if ($dar && !$dar->isError()) {
         $current = $dar->current();
         foreach ($user as $field => $value) {
             if ($field != 'user_id' && $value != $current[$field] && $value !== null) {
                 $stmt[] = $field . ' = ' . $this->da->quoteSmart($value);
             }
         }
         if (count($stmt) > 0) {
             $sql = 'UPDATE user SET ' . implode(', ', $stmt) . ' WHERE user_id = ' . db_ei($user['user_id']);
             return $this->update($sql);
         }
     }
     return false;
 }
Exemplo n.º 3
0
 private function isPasswordUpdatingNeeded($hashed_password)
 {
     return $this->password_handler->isPasswordNeedRehash($hashed_password);
 }
 public function testShouldNotUpdatePasswordWhenNewPasswordIsUserName()
 {
     $_POST['old-password'] = '******';
     $user = $this->loginUser($_POST['old-password']);
     $_POST['new-password'] = $user->field('name');
     $_POST['new-password-confirm'] = $user->field('name');
     $old_password = $user->field('password');
     $request = new NeechyRequest();
     $request->action = 'change-password';
     $handler = new PasswordHandler($request);
     $content = $handler->handle();
     $this->assertPasswordUnchanged($user->field('name'), $old_password);
     $needle = sprintf('<span class="help-block">%s</span>', 'User name and password should not match.');
     $this->assertContains($needle, $content);
 }