mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Merge pull request #12364 from snipe/features/make_2fa_sortable
BREAKING: Partial fix for #12356: Make 2FA sortable in user list
This commit is contained in:
commit
956bd384b0
|
@ -149,6 +149,14 @@ class UsersController extends Controller
|
||||||
$users = $users->where('remote', '=', $request->input('remote'));
|
$users = $users->where('remote', '=', $request->input('remote'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->filled('two_factor_enrolled')) {
|
||||||
|
$users = $users->where('two_factor_enrolled', '=', $request->input('two_factor_enrolled'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('two_factor_optin')) {
|
||||||
|
$users = $users->where('two_factor_optin', '=', $request->input('two_factor_optin'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->filled('start_date')) {
|
if ($request->filled('start_date')) {
|
||||||
$users = $users->where('users.start_date', '=', $request->input('start_date'));
|
$users = $users->where('users.start_date', '=', $request->input('start_date'));
|
||||||
}
|
}
|
||||||
|
@ -157,7 +165,6 @@ class UsersController extends Controller
|
||||||
$users = $users->where('users.end_date', '=', $request->input('end_date'));
|
$users = $users->where('users.end_date', '=', $request->input('end_date'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->filled('assets_count')) {
|
if ($request->filled('assets_count')) {
|
||||||
$users->has('assets', '=', $request->input('assets_count'));
|
$users->has('assets', '=', $request->input('assets_count'));
|
||||||
}
|
}
|
||||||
|
@ -208,11 +215,39 @@ class UsersController extends Controller
|
||||||
default:
|
default:
|
||||||
$allowed_columns =
|
$allowed_columns =
|
||||||
[
|
[
|
||||||
'last_name', 'first_name', 'email', 'jobtitle', 'username', 'employee_num',
|
'last_name',
|
||||||
'assets', 'accessories', 'consumables', 'licenses', 'groups', 'activated', 'created_at',
|
'first_name',
|
||||||
'two_factor_enrolled', 'two_factor_optin', 'last_login', 'assets_count', 'licenses_count',
|
'email',
|
||||||
'consumables_count', 'accessories_count', 'phone', 'address', 'city', 'state',
|
'jobtitle',
|
||||||
'country', 'zip', 'id', 'ldap_import', 'remote', 'start_date', 'end_date',
|
'username',
|
||||||
|
'employee_num',
|
||||||
|
'assets',
|
||||||
|
'accessories',
|
||||||
|
'consumables',
|
||||||
|
'licenses',
|
||||||
|
'groups',
|
||||||
|
'activated',
|
||||||
|
'created_at',
|
||||||
|
'two_factor_enrolled',
|
||||||
|
'two_factor_optin',
|
||||||
|
'last_login',
|
||||||
|
'assets_count',
|
||||||
|
'licenses_count',
|
||||||
|
'consumables_count',
|
||||||
|
'accessories_count',
|
||||||
|
'phone',
|
||||||
|
'address',
|
||||||
|
'city',
|
||||||
|
'state',
|
||||||
|
'country',
|
||||||
|
'zip',
|
||||||
|
'id',
|
||||||
|
'ldap_import',
|
||||||
|
'two_factor_optin',
|
||||||
|
'two_factor_enrolled',
|
||||||
|
'remote',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
];
|
];
|
||||||
|
|
||||||
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
|
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
|
||||||
|
|
|
@ -56,8 +56,8 @@ class UsersTransformer
|
||||||
'permissions' => $user->decodePermissions(),
|
'permissions' => $user->decodePermissions(),
|
||||||
'activated' => ($user->activated == '1') ? true : false,
|
'activated' => ($user->activated == '1') ? true : false,
|
||||||
'ldap_import' => ($user->ldap_import == '1') ? true : false,
|
'ldap_import' => ($user->ldap_import == '1') ? true : false,
|
||||||
'two_factor_activated' => ($user->two_factor_active()) ? true : false,
|
|
||||||
'two_factor_enrolled' => ($user->two_factor_active_and_enrolled()) ? true : false,
|
'two_factor_enrolled' => ($user->two_factor_active_and_enrolled()) ? true : false,
|
||||||
|
'two_factor_optin' => ($user->two_factor_active()) ? true : false,
|
||||||
'assets_count' => (int) $user->assets_count,
|
'assets_count' => (int) $user->assets_count,
|
||||||
'licenses_count' => (int) $user->licenses_count,
|
'licenses_count' => (int) $user->licenses_count,
|
||||||
'accessories_count' => (int) $user->accessories_count,
|
'accessories_count' => (int) $user->accessories_count,
|
||||||
|
|
|
@ -586,6 +586,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
if ((Setting::getSettings()->two_factor_enabled == '1') && ($this->two_factor_optin == '1')) {
|
if ((Setting::getSettings()->two_factor_enabled == '1') && ($this->two_factor_optin == '1')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the 2FA is required for everyone so is implicitly active
|
// If the 2FA is required for everyone so is implicitly active
|
||||||
elseif (Setting::getSettings()->two_factor_enabled == '2') {
|
elseif (Setting::getSettings()->two_factor_enabled == '2') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -594,18 +595,6 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the admin user who created this user
|
|
||||||
*
|
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
|
||||||
* @since [v6.0.5]
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
|
||||||
*/
|
|
||||||
public function createdBy()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(\App\Models\User::class, 'created_by')->withTrashed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether two-factor authorization is required and the user has activated it
|
* Check whether two-factor authorization is required and the user has activated it
|
||||||
* and enrolled a device
|
* and enrolled a device
|
||||||
|
@ -634,6 +623,19 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the admin user who created this user
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v6.0.5]
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||||
|
*/
|
||||||
|
public function createdBy()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(\App\Models\User::class, 'created_by')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function decodePermissions()
|
public function decodePermissions()
|
||||||
{
|
{
|
||||||
|
|
|
@ -268,9 +268,9 @@ class UserPresenter extends Presenter
|
||||||
'formatter' => 'trueFalseFormatter',
|
'formatter' => 'trueFalseFormatter',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'field' => 'two_factor_activated',
|
'field' => 'two_factor_optin',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
'sortable' => false,
|
'sortable' => true,
|
||||||
'switchable' => true,
|
'switchable' => true,
|
||||||
'title' => trans('admin/users/general.two_factor_active'),
|
'title' => trans('admin/users/general.two_factor_active'),
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
|
|
Loading…
Reference in a new issue