Fixes #3777 - correct response for two_factor_actived for user API

This commit is contained in:
snipe 2017-07-29 16:25:42 -07:00
parent 5e47c18d68
commit 0408509fdc
2 changed files with 20 additions and 1 deletions

View file

@ -45,7 +45,7 @@ class UsersTransformer
] : null,
'permissions' => $user->decodePermissions(),
'activated' => ($user->activated =='1') ? true : false,
'two_factor_activated' => ($user->activated =='1') ? true : false,
'two_factor_activated' => ($user->two_factor_active()) ? true : false,
'assets_count' => (int) $user->assets_count,
'licenses_count' => (int) $user->licenses_count,
'accessories_count' => (int) $user->accessories_count,

View file

@ -345,6 +345,25 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
}
/**
* Check whether two-factor authorization is required and the user has activated it
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0]
*
* @return bool
*/
public function two_factor_active () {
if (Setting::getSettings()->two_factor_enabled !='0') {
if (($this->two_factor_optin =='1') && ($this->two_factor_enrolled)) {
return true;
}
}
return false;
}
public function decodePermissions()
{