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

PHP Hashing\Hasher类代码示例

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

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



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

示例1: getNewHash

 /**
  * @param Request $request
  * @param Hasher $hasher
  * @return mixed|string
  */
 protected function getNewHash(Request $request, Hasher $hasher)
 {
     $email = $request->get('email');
     $hash = $hasher->make(time() . 'someRandome123string' . $email);
     $hash = str_replace('/', '_', $hash);
     return $hash;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:12,代码来源:MembershipInvitationController.php


示例2: handle

 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle(UserRepositoryInterface $users, Hasher $hasher)
 {
     if (!($user = $users->findByResetToken($this->token))) {
         throw new DisplayException('auth::reset.error');
     }
     $users->resetPassword($user, $hasher->make($this->password));
 }
开发者ID:ChristianGiupponi,项目名称:Auth,代码行数:12,代码来源:ResetCommand.php


示例3: changePassword

 public function changePassword(ChangePasswordRequest $request, Auth $auth, Hasher $hash)
 {
     $user = $auth->user();
     if ($hash->check($request->password, $user->password) == false) {
         return redirect('changePassword')->withErrors('Senha atual incorreta.');
     }
     $user->password = $hash->make($request->new_password);
     $user->save();
     return redirect('/');
 }
开发者ID:natanaelphp,项目名称:Dividas2.0,代码行数:10,代码来源:ChangePasswordController.php


示例4: handle

 /**
  * Execute the command.
  *
  * @param Hasher $hasher
  * @param UserRepository $users
  * @return User
  * @throws UserAlreadyExistsException
  */
 public function handle(Hasher $hasher, UserRepository $users)
 {
     try {
         $users->findByEmail($this->email);
         throw new UserAlreadyExistsException($this->email);
     } catch (ModelNotFoundException $e) {
         $user = User::register($this->name, $this->email, $hasher->make($this->password), 'admin');
         $users->save($user);
         event(new UserWasRegistered($user));
         return $user;
     }
 }
开发者ID:manishkiozen,项目名称:Cms,代码行数:20,代码来源:RegisterAdministratorUserCommand.php


示例5: handle

 /**
  * @param User $user
  * @param Hasher $hash
  * @param Dispatcher $events
  * @return User
  * @throws Exception
  */
 public function handle(User $user, Hasher $hash, Dispatcher $events)
 {
     $connection = $user->getConnection();
     $connection->beginTransaction();
     //we already have a user with this email.
     try {
         if (!$this->user) {
             $this->user = $user;
             $this->user->email = $this->email;
             $this->user->password = $hash->make($this->password);
             $this->user->save();
         }
         $events->fire(new UserRegistered($this->user, $this->invitation));
         $connection->commit();
         return $this->user;
     } catch (Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:27,代码来源:Signup.php


示例6: hashPassword

 /**
  * @param array $attributes
  *
  * @return array
  */
 protected function hashPassword(array $attributes)
 {
     if (isset($attributes['password']) && isset($attributes['password_confirmation']) && $attributes['password'] == $attributes['password_confirmation']) {
         $attributes['password'] = $attributes['password_confirmation'] = $this->hasher->make($attributes['password']);
     }
     return $attributes;
 }
开发者ID:Viktor-V,项目名称:LPanel,代码行数:12,代码来源:UserRepository.php


示例7: fire

 public function fire(array $data)
 {
     $this->validator->setScenario('register')->validate($data);
     $data['password'] = $this->hasher->make($data['password']);
     $user = $this->userModel->create($data);
     event(new UserRegistered($user));
     return $user;
 }
开发者ID:tajrish,项目名称:api,代码行数:8,代码来源:RegisterService.php


示例8: hash

 /**
  * Return a hash that has no / in it suited for url generated.
  *
  * @param $value
  * @return string
  */
 protected function hash($value)
 {
     $hash = $this->hasher->make($value);
     while (strpos($hash, '/') !== false) {
         $hash = $this->hasher->make($value);
     }
     return $hash;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:14,代码来源:TokenRepository.php


示例9: fire

 public function fire(array $data)
 {
     $this->validator->setScenario('login')->validate($data);
     $user = $this->user->where('email', $data['email'])->first();
     if (!$this->hasher->check($data['password'], $user->password)) {
         throw new LoginFailedException();
     }
     return $user;
 }
开发者ID:tajrish,项目名称:api,代码行数:9,代码来源:LoginService.php


示例10: create

 /**
  * Create a new user in the database.
  *
  * @param  array $data
  * @return \Begin\User
  */
 public function create(array $data)
 {
     $user = $this->getNew();
     $user->name = $data['name'];
     $user->email = $data['email'];
     $user->password = $this->hasher->make($data['password']);
     $user->save();
     return $user;
 }
开发者ID:rajabishek,项目名称:begin,代码行数:15,代码来源:UserRepository.php


示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $post = $this->post->bySlug($request->segment(2));
     if ($post->visibility_id == 2) {
         if (!$this->hash->check(Input::get('password'), $post->password)) {
             return redirect()->route('blog.askPassword', [$post->slug])->with('wrong_password', 'Please provide a valid password to view this post');
         }
     }
     return $next($request);
 }
开发者ID:raccoonsoftware,项目名称:Blogify,代码行数:17,代码来源:ProtectedPost.php


示例12: make

 /**
  * @param string $email
  * @param string $password
  * @param bool   $isStaff
  *
  * @throws \DomainException
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return User
  */
 public function make(string $email, string $password, bool $isStaff) : User
 {
     if (!$this->validate($email, $password)) {
         throw new DomainException();
     }
     $user = new User();
     $user->email = $email;
     $user->password = $this->hasher->make($password);
     if ($isStaff) {
         $staffRole = $this->roleResource->mustFindByName(Role::STAFF);
         $staffRole->users()->save($user);
     }
     return $user;
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:24,代码来源:MakeUser.php


示例13: verify

 /**
  * 비회원 작성 글 인증 확인
  *
  * @param ItemEntity $item       board item entity
  * @param string     $email      email
  * @param string     $certifyKey 인증 암호
  * @return bool
  */
 public function verify(ItemEntity $item, $email, $certifyKey)
 {
     if ($email != $item->email) {
         return false;
     }
     return $this->hasher->check($certifyKey, $item->certifyKey);
 }
开发者ID:khongchi,项目名称:plugin-board,代码行数:15,代码来源:IdentifyManager.php


示例14: fire

 public function fire(array $data)
 {
     $this->validator->setScenario('recoverPassword')->validate($data);
     $token = $this->tokenHelper->validate($data['token']);
     if ($token === false) {
         $this->response()->errorBadRequest(trans('messages.token_invalid'));
     }
     $user = $token->tokenable->first();
     if ($user === NULL) {
         $this->response()->errorBadRequest(trans('messages.token_invalid'));
     }
     $user->password = $this->hasher->make($data['password']);
     $user->save();
     $token->delete();
     return $user;
 }
开发者ID:tajrish,项目名称:api,代码行数:16,代码来源:RecoverPasswordService.php


示例15: postReset

 public function postReset()
 {
     $credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
     $response = $this->password->reset($credentials, function ($user, $password) {
         $user->password = $this->hasher->make($password);
         $user->save();
     });
     switch ($response) {
         case $this->password->INVALID_PASSWORD:
         case $this->password->INVALID_TOKEN:
         case $this->password->INVALID_USER:
             return $this->redirector->back()->with('error', $this->translator->get($response));
         case $this->password->PASSWORD_RESET:
             return $this->redirector->to('/');
     }
 }
开发者ID:PhonemeCms,项目名称:cms,代码行数:16,代码来源:RemindersController.php


示例16: verify

 /**
  * 비회원 작성 글 인증 확인
  *
  * @param Board  $board      board model
  * @param string $email      email
  * @param string $certifyKey 인증 암호
  * @return bool
  */
 public function verify(Board $board, $email, $certifyKey)
 {
     if ($email != $board->email) {
         return false;
     }
     return $this->hasher->check($certifyKey, $board->certifyKey);
 }
开发者ID:xpressengine,项目名称:plugin-board,代码行数:15,代码来源:IdentifyManager.php


示例17: storeOrUpdatePost

 /**
  * @return \jorenvanhocht\Blogify\Models\Post
  */
 private function storeOrUpdatePost()
 {
     if (!empty($this->data->hash)) {
         $post = $this->post->byHash($this->data->hash);
     } else {
         $post = new Post();
         $post->hash = $this->blogify->makeHash('posts', 'hash', true);
     }
     $post->slug = $this->data->slug;
     $post->title = $this->data->title;
     $post->content = $this->data->post;
     $post->status_id = $this->status->byHash($this->data->status)->id;
     $post->publish_date = $this->data->publishdate;
     $post->user_id = $this->user->byHash($this->auth_user->hash)->id;
     $post->reviewer_id = $this->user->byHash($this->data->reviewer)->id;
     $post->visibility_id = $this->visibility->byHash($this->data->visibility)->id;
     $post->category_id = $this->category->byHash($this->data->category)->id;
     $post->being_edited_by = null;
     if (!empty($this->data->password)) {
         $post->password = $this->hash->make($this->data->password);
     }
     $post->save();
     $post->tag()->sync($this->tags);
     return $post;
 }
开发者ID:raccoonsoftware,项目名称:Blogify,代码行数:28,代码来源:PostsController.php


示例18: validateCredentials

 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserContract $user, array $credentials)
 {
     $credentialsValidated = false;
     // If the user is set AND, either of auth_type 'internal' or with
     // auth_type unset or null, then validate against the stored
     // password hash. Otherwise if the LDAP authentication
     // method is enabled, try it.
     if (isset($user) && (isset($user->auth_type) && $this->ldapConfig['label_internal'] === $user->auth_type || !isset($user->auth_type))) {
         $plain = $credentials['password'];
         $credentialsValidated = $this->hasher->check($plain, $user->getAuthPassword());
     } else {
         if ($this->ldapConfig['enabled'] && $this->ldapConfig['label_ldap'] === $user->auth_type) {
             // Validate credentials against LDAP/AD server.
             $credentialsValidated = $this->validateLDAPCredentials($credentials);
             // If validated and config set to resync group membership on login.
             if ($credentialsValidated && $this->ldapConfig['resync_on_login']) {
                 // First, revoke membership to all groups marked to 'resync_on_login'.
                 $this->revokeMembership($user);
                 // Then replicate group membership.
                 $this->replicateMembershipFromLDAP($user);
             }
         }
     }
     return $credentialsValidated;
 }
开发者ID:syardumi,项目名称:my-eloquent-ldap,代码行数:32,代码来源:EloquentLDAPUserProvider.php


示例19: testGeneratesPasswordIfNoneGiven

 /**
  * Should generate a password if none given.
  */
 public function testGeneratesPasswordIfNoneGiven()
 {
     $this->hasher->expects($this->atLeastOnce())->method('make')->with($this->isType('string'))->willReturn($this->generator()->anyString());
     $this->userResource->expects($this->atLeastOnce())->method('setAttribute')->withConsecutive($this->anything(), ['password', $this->isType('string')]);
     $tester = $this->commandTester($this->makeUser);
     $tester->execute([]);
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:10,代码来源:MakeUserConsoleTest.php


示例20: resetPassword

 /**
  * Resets a given users password
  *
  * @param User $user
  * @param $pwd
  * @return User
  */
 public function resetPassword(User $user, $pwd)
 {
     $hashed = $this->hasher->make($pwd);
     $user->setPassword(new HashedPassword($hashed));
     $this->userRepo->update($user);
     return $user;
 }
开发者ID:bakgat,项目名称:notos,代码行数:14,代码来源:UserService.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Mail\Mailer类代码示例发布时间:2022-05-23
下一篇:
PHP Foundation\Application类代码示例发布时间: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