Refactor tests and code to handle new 2FA methods.

This commit is contained in:
James Cole
2019-08-04 10:27:37 +02:00
parent d3be043aa7
commit 62b5cf04ad
12 changed files with 12 additions and 662 deletions

View File

@@ -245,21 +245,14 @@ class UserRepository implements UserRepositoryInterface
$return = [];
// two factor:
die('this method references 2FA and must be refactored.');
$is2faEnabled = app('preferences')->getForUser($user, 'twoFactorAuthEnabled', false)->data;
$has2faSecret = null !== app('preferences')->getForUser($user, 'twoFactorAuthSecret');
$return['has_2fa'] = false;
if ($is2faEnabled && $has2faSecret) {
$return['has_2fa'] = true;
}
$return['is_admin'] = $this->hasRole($user, 'owner');
$return['blocked'] = 1 === (int)$user->blocked;
$return['blocked_code'] = $user->blocked_code;
$return['accounts'] = $user->accounts()->count();
$return['journals'] = $user->transactionJournals()->count();
$return['transactions'] = $user->transactions()->count();
$return['attachments'] = $user->attachments()->count();
$return['has_2fa'] = $user->mfa_secret !== null;
$return['is_admin'] = $this->hasRole($user, 'owner');
$return['blocked'] = 1 === (int)$user->blocked;
$return['blocked_code'] = $user->blocked_code;
$return['accounts'] = $user->accounts()->count();
$return['journals'] = $user->transactionJournals()->count();
$return['transactions'] = $user->transactions()->count();
$return['attachments'] = $user->attachments()->count();
$return['attachments_size'] = $user->attachments()->sum('size');
$return['bills'] = $user->bills()->count();
$return['categories'] = $user->categories()->count();