makeHash() public méthode

For integration with other applications, this function can be overwritten to instead use the other package password checking algorithm.
Since: 2.5.0
public makeHash ( string $password ) : string
$password string Plain text user password to hash
Résultat string The hash string of the password
 public function testUserProvider()
 {
     $userProvider = new AuthUserProvider(null);
     $passwordService = new PasswordService();
     $user = new User();
     $user->user_pass = $passwordService->makeHash('admin');
     $this->assertTrue($userProvider->validateCredentials($user, ['password' => 'admin']));
     $this->assertFalse($userProvider->validateCredentials($user, ['password' => 'admin`']));
     $user->user_pass = $passwordService->makeHash('(V-._p@q8sK=TK1QYHIi');
     $this->assertTrue($userProvider->validateCredentials($user, ['password' => '(V-._p@q8sK=TK1QYHIi']));
     $this->assertFalse($userProvider->validateCredentials($user, ['password' => '(V-._p@q8sK=TK1QYHIi)`']));
     $user->user_pass = $passwordService->makeHash(')_)E~O79}?w+5"4&6{!;ct>656Lx~5');
     $this->assertTrue($userProvider->validateCredentials($user, ['password' => ')_)E~O79}?w+5"4&6{!;ct>656Lx~5']));
     $this->assertFalse($userProvider->validateCredentials($user, ['password' => ') )E~O79}?w+5"4&6{!;ct>656Lx~5`']));
 }
Exemple #2
0
 /**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword $user
  * @param  string $password
  * @return void
  */
 protected function resetPassword($user, $password)
 {
     $passwordService = new PasswordService();
     $user->user_pass = $passwordService->makeHash($password);
     $user->save();
     Auth::guard($this->getGuard())->login($user);
 }