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

@@ -125,16 +125,10 @@ class UserController extends Controller
$users = $this->repository->all();
// add meta stuff.
die('the 2FA references here should be refactored.');
$users->each(
function (User $user) {
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
$preferences = app('preferences')->getArrayForUser($user, $list);
$user->isAdmin = $this->repository->hasRole($user, 'owner');
$is2faEnabled = 1 === $preferences['twoFactorAuthEnabled'];
$has2faSecret = null !== $preferences['twoFactorAuthSecret'];
$user->has2FA = ($is2faEnabled && $has2faSecret);
$user->prefs = $preferences;
$user->has2FA = null !== $user->mfa_secret;
}
);