本文整理汇总了PHP中Illuminate\Contracts\Hashing\Hasher类的典型用法代码示例。如果您正苦于以下问题:PHP Hasher类的具体用法?PHP Hasher怎么用?PHP Hasher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Hasher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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));
}
示例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('/');
}
示例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;
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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;
}
示例12: 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);
}
示例13: 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;
}
示例14: 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('/');
}
}
示例15: 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);
}