當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Passwords::verify方法代碼示例

本文整理匯總了PHP中Nette\Security\Passwords::verify方法的典型用法代碼示例。如果您正苦於以下問題:PHP Passwords::verify方法的具體用法?PHP Passwords::verify怎麽用?PHP Passwords::verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Security\Passwords的用法示例。


在下文中一共展示了Passwords::verify方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: authenticate

 /**
  * @param array $credentials
  * @return Identity
  * @throws AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $user = $this->orm->users->getByEmail($email);
     if (!$user) {
         throw new AuthenticationException('auth.flash.wrongUsername', self::IDENTITY_NOT_FOUND);
     }
     if (!$user->password) {
         throw new AuthenticationException('auth.flash.notSet', self::PASSWORD_NOT_SET);
     }
     $plainHash = $this->aes->decrypt($user->password);
     if (strpos($user->password, 'old-password;') === 0) {
         $this->authOldPassword($password, $user);
     } else {
         if (!Passwords::verify($password, $plainHash)) {
             throw new AuthenticationException('auth.flash.wrongPassword', self::INVALID_CREDENTIAL);
         }
     }
     if (Passwords::needsRehash($plainHash)) {
         $plainHash = Passwords::hash($password);
         $user->password = $this->aes->encrypt($plainHash);
         $this->orm->flush();
     }
     return new Identity($user->id);
 }
開發者ID:VasekPurchart,項目名稱:khanovaskola-v3,代碼行數:30,代碼來源:Authenticator.php

示例2: authenticate

 /**
  * Performs an authentication.
  *
  * @param array $credentials
  *
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $user = $this->userRepository->findOneBy(["userName" => $username]);
     $authExt = false;
     foreach ($this->authDrivers as $authDriver) {
         $authDriver->setUp($this->userRepository, $this->roleRepository, $this->userActivityRepository);
         if ($authExt = $authDriver->authenticate($username, $password, $user)) {
             if ($user) {
                 $user->authMethod = $authDriver->getName();
                 break;
             } else {
                 $authExt = false;
             }
         }
     }
     if (!$authExt) {
         if (!$user) {
             throw new Security\AuthenticationException('Wrong username.', self::IDENTITY_NOT_FOUND);
         } elseif (!Security\Passwords::verify($password, $this->userRepository->getPassword($user))) {
             throw new Security\AuthenticationException('Wrong password.', self::INVALID_CREDENTIAL);
         }
     }
     // update lastLogged
     $user->lastLogged = new DateTime();
     $this->userRepository->save($user);
     $userActivity = new UserActivity();
     $userActivity->userId = $user->id;
     $userActivity->type = "login";
     $this->userActivityRepository->save($userActivity);
     return new Security\Identity($user->id, $user->roles, $user);
 }
開發者ID:mepatek,項目名稱:usermanager,代碼行數:40,代碼來源:Authenticator.php

示例3: authenticate

 /**
  * Performs an authentication against e.g. database.
  * and returns IIdentity on success or throws AuthenticationException
  * @var array $credentials
  * @return Nette\Security\IIdentity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     if (is_null($password)) {
         $user = $this->manager->getItem($username);
     } else {
         $user = $this->manager->getUserByUsername($username);
         if (is_null($user->password)) {
             throw new Trejjam\Authorization\User\AuthenticatorException('User has not have defined password.', Trejjam\Authorization\User\AuthenticatorException::NOT_DEFINED_PASSWORD);
         } else {
             if (!Nette\Security\Passwords::verify($password, $user->password)) {
                 throw new Trejjam\Authorization\User\AuthenticatorException('The password is incorrect.', Trejjam\Authorization\User\AuthenticatorException::INVALID_CREDENTIAL);
             } else {
                 if (Nette\Security\Passwords::needsRehash($user->password)) {
                     $this->manager->changePassword($user, $password);
                 }
             }
         }
     }
     if ($this->manager->isEnableLogin($user)) {
         $baseUserArr = (array) $this->manager->getUserInfo($user);
         $baseUserArr["login_time"] = new Nette\Utils\DateTime();
         $role = $this->acl->getUserRoles($user);
         return new Identity($user->id, $role, $baseUserArr);
     } else {
         //this may not happen
         throw new Trejjam\Authorization\User\AuthenticatorException();
     }
 }
開發者ID:trejjam,項目名稱:authorization,代碼行數:36,代碼來源:Authenticator.php

示例4: authenticate

 /**
  * Performs an authentication.
  * @param array $credentials (string $username, string $password)
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $row = $this->database->table('user')->where('username', $username)->fetch();
     if (!$row) {
         throw new Security\AuthenticationException('Uživatel s tímto jménem neexistuje.', self::IDENTITY_NOT_FOUND);
     } elseif (!Security\Passwords::verify($password, $row->password)) {
         throw new Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
     } elseif (!$row->active) {
         throw new Security\AuthenticationException('Účet není aktivovaný.', self::NOT_APPROVED);
     } elseif (Security\Passwords::needsRehash($row->password)) {
         $row->update(array('password' => Security\Passwords::hash($password)));
     }
     $arr = $row->toArray();
     unset($arr['password']);
     $roles = $row->related('privilege')->fetch()->toArray();
     unset($roles['user_id']);
     //adds privileges
     array_walk($roles, function (&$value, $key) use(&$roles) {
         if ($value != NULL) {
             $value = $key . ' - ' . $value;
         }
     });
     return new Security\Identity($row->id, $roles, $arr);
 }
開發者ID:patrickkusebauch,項目名稱:27skauti,代碼行數:31,代碼來源:Authenticator.php

示例5: editUser

 public function editUser($values, $user_id)
 {
     //        $temp = $this->database->table('user')->where('email = ?', $values->email)->fetch();
     $row = $this->database->table('user')->where('id', $user_id)->fetch();
     if (!NS\Passwords::verify($values->oldPassword, $row->password)) {
         //            throw new NS\AuthenticationException('Špatné heslo.');
         $check = 0;
     } else {
         if ($values->newPassword != NULL) {
             $this->database->table('user')->where('id', $user_id)->update(['password' => Passwords::hash($values->newPassword)]);
         }
         if ($values->username != NULL) {
             $this->database->table('user')->where('id', $user_id)->update(['username' => $values->username]);
         }
         $check = 1;
     }
     //        $check = 0;
     //        if ((!$temp)) $check = 1;
     //        if ($check) {
     //            $this->database->table('user')->where('id', $user_id)->update([
     //                'username' => $values->username,
     //                'password' => Passwords::hash($values->newPassword),
     //            ]);
     //
     //            /*$mail = new Message;
     //            $mail->setFrom('BrNOC bot <bot@brnoc.cz>')
     //                ->addTo($values->email)
     //                ->setSubject('Potvrzení příhlášení')
     //                ->setBody("Byl jsi přihlášen jako účastník BrNOCi 2015. \n \nBrNOC tým");*/
     //        }
     return $check;
 }
開發者ID:norik16,項目名稱:TripMap,代碼行數:32,代碼來源:SettingsModel.php

示例6: authenticate

 /**
  * Performs an authentication.
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     if (!Passwords::verify($credentials[1], $this->database->table('option')->get('password')->value)) {
         throw new Nette\Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
     }
     return new Nette\Security\Identity(NULL, NULL, NULL);
 }
開發者ID:vokracko,項目名稱:SimpleReader,代碼行數:12,代碼來源:UserManager.php

示例7: onBeforeChange

 public function onBeforeChange(Form $form, User $user)
 {
     $values = $form->getValues();
     if (!Passwords::verify($values['currentPassword'], $user->password)) {
         $this->flashMessage('Heslo nelze změnit, protože nesouhlasí
              Vaše aktuální heslo.', 'warning');
         $this->redirect('this');
     }
 }
開發者ID:blitzik,項目名稱:vycetky-doctrine,代碼行數:9,代碼來源:AccountPasswordControl.php

示例8: updateUserPasswd

 public function updateUserPasswd($curentPasswd, $newPasswd)
 {
     $row = $this->database->table(self::USER_TABLE_NAME)->where(self::USER_COLUMN_ID, $this->user->identity->id)->fetch();
     if (Passwords::verify($curentPasswd, $row[self::USER_COLUMN_PASSWORD])) {
         $this->database->table(self::USER_TABLE_NAME)->where(self::USER_COLUMN_ID, $this->user->identity->id)->update(array(self::USER_COLUMN_PASSWORD => Passwords::hash($newPasswd)));
         return True;
     } else {
         return False;
     }
 }
開發者ID:romanbartl,項目名稱:BusinessPlann,代碼行數:10,代碼來源:UserManager.php

示例9: authenticate

 /**
  * @param array $credentials
  * @throws AuthenticationException
  * @return Identity
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     /** @var User $user */
     $user = $this->userDao->findOneBy(['username' => $username]);
     if (!$user || !Passwords::verify($password, $user->getPassword())) {
         throw new AuthenticationException('Invalid username or password.', self::IDENTITY_NOT_FOUND);
     }
     return new Identity($user->getUserId(), NULL, $user->getLoginData());
 }
開發者ID:peterkrejci,項目名稱:music-collection,代碼行數:15,代碼來源:UserModel.php

示例10: verifyPassword

 /**
  * Compare $password to origin
  * @param $password
  * @return bool
  */
 public function verifyPassword($password)
 {
     if (Passwords::verify($password, $this->password)) {
         if (Passwords::needsRehash($this->password)) {
             $this->setPassword($password);
         }
         return TRUE;
     }
     return FALSE;
 }
開發者ID:studna,項目名稱:common,代碼行數:15,代碼來源:Password.php

示例11: checkInstallationPassword

 /**
  * Funkce kontrolující, zda zadané heslo odpovídá hodnotě uložené v configu
  * @param string $password
  * @return bool
  */
 public function checkInstallationPassword($password)
 {
     $passwordHash = $this->data['parameters']['install']['password'];
     if (Passwords::verify($password, $passwordHash)) {
         if (Passwords::needsRehash($password)) {
             $this->saveInstallationPassword($password);
         }
         return true;
     }
     return false;
 }
開發者ID:kizi,項目名稱:easyminer-easyminercenter,代碼行數:16,代碼來源:ConfigManager.php

示例12: authenticate

 /**
  * @param array $credentials
  * @return \Nette\Security\Identity
  * @throws \Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $user = $this->repository->findUserByName($username);
     if (!is_null($user) && \Nette\Security\Passwords::verify($password, $user->getPassword())) {
         $group = $this->repository->findGroupById($user->getGroupId());
         return new \Nette\Security\Identity($user->id, $group->getName(), $user->getIdentity());
     } else {
         throw new \Nette\Security\AuthenticationException($this->t("forms.sign.errors.wrong-credentials"), self::IDENTITY_NOT_FOUND);
     }
 }
開發者ID:JZechy,項目名稱:ZBox,代碼行數:16,代碼來源:Authenticator.php

示例13: changePassword

 public function changePassword($userId, $oldPassword, $newPassword)
 {
     $user = $this->get($userId);
     if (Nette\Security\Passwords::verify($oldPassword, $user->passwordHash)) {
         $user->passwordHash = Nette\Security\Passwords::hash($newPassword);
         $this->em->flush();
         return TRUE;
     } else {
         return FALSE;
     }
 }
開發者ID:honya121,項目名稱:sklad-web,代碼行數:11,代碼來源:UserFacade.php

示例14: authenticate

 function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $user = $this->user_service->getByLogin($username);
     if (!$user) {
         throw new AuthenticationException('Přihlášení se nezdařilo.');
     }
     if (!Passwords::verify($password, $user->password)) {
         throw new AuthenticationException('Přihlášení se nezdařilo.');
     }
     return new Identity($user->id_user);
 }
開發者ID:bares43,項目名稱:bachelor-thesis-survey,代碼行數:12,代碼來源:Authenticator.php

示例15: passwordChangeFormSucceeded

 public function passwordChangeFormSucceeded(Form $form, $values)
 {
     $user = $this->userFacade->findOneById($this->user->getId());
     if (!Passwords::verify($values->actualPassword, $user->hash)) {
         $form->addError("Zadal si špatné aktuální heslo. Zkus to znovu!");
     } else {
         $user->changePassword($values->password);
         $this->userFacade->save($user);
         $form->getPresenter()->flashMessage("Tvoje heslo bylo úspěšně změněno", "alert-success");
         $form->getPresenter()->redirect("this");
     }
 }
開發者ID:jaromir92,項目名稱:Sportwin,代碼行數:12,代碼來源:PasswordChangeForm.php


注:本文中的Nette\Security\Passwords::verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。