Skip to content

Instantly share code, notes, and snippets.

@adelarcubs
Last active March 9, 2017 21:42
Show Gist options
  • Save adelarcubs/a5e3c5506a4c8c9f3670312ee01a266b to your computer and use it in GitHub Desktop.
Save adelarcubs/a5e3c5506a4c8c9f3670312ee01a266b to your computer and use it in GitHub Desktop.
<?php
$userEmail = 'test@test.com';
$userPassword = '123456';
// Using Doctrine for example
$user = $repository->findByEmail($userEmail);
if(password_verify($userPassword, $user->getPassword())){
$options = ['cost' => 10];
if(password_needs_rehash($user->getPassword(), PASSWORD_DEFAULT, $options)){
$hash = password_hash($userPassword, PASSWORD_DEFAULT, $options);
// save $hash as a NEW password on database
}
// DO LOGIN
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment