Skip to content

Instantly share code, notes, and snippets.

@adelarcubs
Last active March 9, 2017 21:42
<?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