firefly-iii/app/Http/Controllers/Admin/UserController.php

65 lines
2.0 KiB
PHP
Raw Normal View History

2016-04-03 00:07:17 -05:00
<?php
/**
* UserController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
declare(strict_types = 1);
2016-04-03 00:07:17 -05:00
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Preferences;
/**
* Class UserController
*
* @package FireflyIII\Http\Controllers\Admin
*/
class UserController extends Controller
{
/**
* @param UserRepositoryInterface $repository
*/
public function index(UserRepositoryInterface $repository)
{
$title = strval(trans('firefly.administration'));
$mainTitleIcon = 'fa-hand-spock-o';
$subTitle = strval(trans('firefly.user_administration'));
$subTitleIcon = 'fa-users';
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
2016-04-27 03:38:51 -05:00
$users = $repository->all();
2016-04-03 00:07:17 -05:00
// add meta stuff.
$users->each(
function (User $user) use ($confirmAccount) {
2016-04-03 03:51:37 -05:00
// is user activated?
2016-04-27 03:38:51 -05:00
$isConfirmed = Preferences::getForUser($user, 'user_confirmed', false)->data;
$user->activated = true;
2016-04-03 00:07:17 -05:00
if ($isConfirmed === false && $confirmAccount === true) {
$user->activated = false;
}
2016-04-03 03:51:37 -05:00
$user->isAdmin = $user->hasRole('owner');
2016-04-27 03:38:51 -05:00
$is2faEnabled = Preferences::getForUser($user, 'twoFactorAuthEnabled', false)->data;
$has2faSecret = !is_null(Preferences::getForUser($user, 'twoFactorAuthSecret'));
$user->has2FA = false;
2016-04-03 03:51:37 -05:00
if ($is2faEnabled && $has2faSecret) {
$user->has2FA = true;
}
2016-04-03 00:07:17 -05:00
}
);
return view('admin.users.index', compact('title', 'mainTitleIcon', 'subTitle', 'subTitleIcon', 'users'));
}
2016-04-08 10:54:25 -05:00
}