• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Security\Passwords类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Nette\Security\Passwords的典型用法代码示例。如果您正苦于以下问题:PHP Passwords类的具体用法?PHP Passwords怎么用?PHP Passwords使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Passwords类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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


示例2: 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 <[email protected]>')
     //                ->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


示例3: registerFormSucceeded

 public function registerFormSucceeded($form, $values)
 {
     $hash = \Nette\Security\Passwords::hash($values['password']);
     $reguser = $this->database->table('users')->insert(array('username' => $values->username, 'password' => $hash, 'email' => $values->email));
     $this->flashMessage("Gratulujeme. Boli ste úspešne zaregistrovaný. Môžte sa prihlásiť do aplikácie.", 'success');
     $this->redirect('Sign:in');
 }
开发者ID:misnlog,项目名称:2ndHandRadar,代码行数:7,代码来源:RegistrationPresenter.php


示例4: 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


示例5: 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


示例6: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @return void
  */
 public function add($username, $password)
 {
     $user = new Entities\UserEntity();
     $user->setUsername($username);
     $user->setPassword(Passwords::hash($password));
     $this->userRepository->save($user);
 }
开发者ID:janlanger,项目名称:nette-skeleton,代码行数:13,代码来源:UserManager.php


示例7: onSuccess

 public function onSuccess()
 {
     $v = $this->values;
     $user = $this->orm->users->getByEmail($v->email);
     if ($user && $user->registered) {
         $this->addError('duplicate');
         return;
     }
     if (!$user) {
         $user = new User();
         $user->email = $v->email;
         $this->orm->users->attach($user);
     }
     $user->gender = $v->gender;
     $user->setNames($v->name);
     $user->registered = TRUE;
     $plainHash = Passwords::hash($v->password);
     $user->password = $this->aes->encrypt($plainHash);
     $this->orm->flush();
     /** @var Auth $presenter */
     $presenter = $this->presenter;
     $presenter->user->login(new Identity($user->id));
     $this->iLog('auth.registration.password', ['entropy' => $this->entropy->compute($v->password, $user)]);
     $presenter->onLogin($user, TRUE);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:25,代码来源:Registration.php


示例8: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @param  string
  * @return void
  * @throws DuplicateNameException
  */
 public function add($username, $email, $password)
 {
     try {
         $this->database->table(self::TABLE_NAME)->insert([self::COLUMN_NAME => $username, self::COLUMN_PASSWORD_HASH => Passwords::hash($password), self::COLUMN_EMAIL => $email]);
     } catch (Nette\Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:nette,项目名称:sandbox,代码行数:16,代码来源:UserManager.php


示例9: uprav

 /**
  * Upraví
  * @param int
  * @param string
  * @param string
  * @param string
  * @return int
  */
 public function uprav($id, $jmeno, $heslo, $role)
 {
     $u = array(self::COLUMN_NAME => $jmeno, self::COLUMN_ROLE => $role);
     if ($heslo) {
         $u[self::COLUMN_PASSWORD_HASH] = Passwords::hash($heslo);
     }
     return $this->database->table(self::TABLE_NAME)->where(self::COLUMN_ID, (int) $id)->update($u);
 }
开发者ID:myiyk,项目名称:vote,代码行数:16,代码来源:UserManager.php


示例10: hashPassword

 public function hashPassword(ArrayHash $values)
 {
     if ($values->password) {
         $values->password = Passwords::hash($values->password);
     } else {
         unset($values->password);
     }
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:8,代码来源:UserFormFactory.php


示例11: add

 /**
  * @param \stdClass $user
  * @throws DuplicateNameException
  */
 public function add(\stdClass $user)
 {
     try {
         $this->userModel->add(['username' => $user->username, 'email' => $user->email, 'password' => Passwords::hash($user->password), 'first_name' => $user->firstName, 'last_name' => $user->lastName]);
     } catch (UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:janeczko,项目名称:vpp,代码行数:12,代码来源:UserManager.php


示例12: update

 public function update($userID, $login, $password, $email)
 {
     try {
         $this->database->table(self::TABLE_NAME)->get($userID)->update(array(self::COLUMN_NAME => $login, self::COLUMN_PASSWORD_HASH => Passwords::hash($password), self::COLUMN_EMAIL => $email));
     } catch (Nette\Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:sifuraz,项目名称:-closed-myApp,代码行数:8,代码来源:UserManager.php


示例13: renderDefault

 /**
  * @param string|null $password
  */
 public function renderDefault($password = NULL)
 {
     if (!empty($password)) {
         $this->template->hash = \Nette\Security\Passwords::hash($password);
     }
     $this->setLayout(FALSE);
     $this->template->setFile(__DIR__ . '/template.latte');
 }
开发者ID:nella,项目名称:simple-hash-authenticator,代码行数:11,代码来源:PasswordHashGeneratorPresenter.php


示例14: add

 /**
  * Adds new user.
  *
  * @param  string
  * @param  string
  */
 public function add($username, $password)
 {
     try {
         $this->connection->query('INSERT INTO [' . table(self::TABLE_NAME) . ']', array(self::COLUMN_NAME => $username, self::COLUMN_PASSWORD_HASH => Passwords::hash($password)));
     } catch (Exception $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:jan-martinek,项目名称:peer-blender,代码行数:14,代码来源:UserRepository.php


示例15: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @param  string
  * @return void
  * @throws DuplicateNameException
  */
 public function add($username, $password, $role = 'guest')
 {
     try {
         $this->db->insert(self::TABLE_NAME, [self::COLUMN_NAME => $username, self::COLUMN_PASSWORD_HASH => Passwords::hash($password), self::COLUMN_ROLE => $role])->execute();
     } catch (Nette\Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:svatekr,项目名称:rsrs,代码行数:16,代码来源:UserManager.php


示例16: add

 /**
  * @param string $username
  * @param string $password
  * @param string $fullname
  */
 public function add($username, $password, $fullname)
 {
     $user = new User();
     $user->setUsername($username);
     $user->setPassword(Passwords::hash($password));
     $user->setFullname($fullname);
     $this->userDao->safePersist($user);
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:13,代码来源:UserModel.php


示例17: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @param  string
  * @param  int
  * @return void
  */
 public function add($sUserName, $sPassword, $sEmail, $iRole)
 {
     try {
         $this->oDatabase->table(self::TABLE_NAME)->insert(array(self::COLUMN_NAME => $sUserName, self::COLUMN_PASSWORD_HASH => Passwords::hash($sPassword), self::COLUMN_MAIL => $sEmail, self::COLUMN_TYP => $iRole));
     } catch (Nette\Database\UniqueConstraintViolationException $oException) {
         throw new DuplicateNameException();
     }
 }
开发者ID:GreenOceanCZ,项目名称:kelio-test,代码行数:16,代码来源:UserManager.php


示例18: 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


示例19: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @return void
  */
 public function add($username, $email, $password)
 {
     Passwords::validateNew($password);
     try {
         $this->db->table(static::TABLE_NAME)->insert(array(static::COLUMN_NAME => $username, static::COLUMN_EMAIL => $email, static::COLUMN_PASSWORD_HASH => Security\Passwords::hash($password)));
     } catch (Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:klajmajk,项目名称:futro,代码行数:15,代码来源:UserManager.php


示例20: add

 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @param  string
  * @param  DateTime
  * @return void
  */
 public function add($username, $password, $email, $date)
 {
     try {
         $data = array('username' => $username, 'password' => Passwords::hash($password), 'email' => $email, 'date' => $date, 'role' => 'user');
         $this->usersFacade->update($data);
     } catch (Nette\Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }
开发者ID:04EO,项目名称:hup-nette,代码行数:17,代码来源:UserManager.php



注:本文中的Nette\Security\Passwords类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Security\User类代码示例发布时间:2022-05-23
下一篇:
PHP Reflection\ClassType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap