Properly check hashes, issue #456

This commit is contained in:
James Cole 2016-12-12 17:17:36 +01:00
parent ffca4b0543
commit 4dccf7b7b5
3 changed files with 11 additions and 4 deletions

View File

@ -84,6 +84,7 @@ class UserEventHandler
*/
public function saveEmailAddress(DeletedUser $event): bool
{
Preferences::mark();
$email = hash('sha256', $event->email);
Log::debug(sprintf('Hash of email is %s', $email));
/** @var Configuration $configuration */
@ -94,7 +95,10 @@ class UserEventHandler
}
$content[] = $email;
$configuration->data = $content;
$configuration->save();
Log::debug('New content of deleted_users is ', $content);
FireflyConfig::set('deleted_users', $content);
Preferences::mark();
return true;
}

View File

@ -100,6 +100,8 @@ class RegisterController extends Controller
$hash = hash('sha256', $data['email']);
$configuration = FireflyConfig::get('deleted_users', []);
$set = $configuration->data;
Log::debug(sprintf('Hash of email is %s', $hash));
Log::debug('Hashes of deleted users: ', $set);
if (in_array($hash, $set)) {
// user already deleted, cannot re-register :(
$validator->getMessageBag()->add('email', (string)trans('validation.deleted_user'));
@ -108,6 +110,7 @@ class RegisterController extends Controller
}
$user = $this->create($request->all());
// trigger user registration event:

View File

@ -91,12 +91,12 @@ class FireflyConfig
}
/**
* @param $name
* @param string $value
* @param string $name
* @param $value
*
* @return Configuration
*/
public function set($name, $value): Configuration
public function set(string $name, $value): Configuration
{
Log::debug('Set new value for ', ['name' => $name]);
$config = Configuration::whereName($name)->first();