mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-09-23 10:23:23 +00:00
Provide a stable method for checking whether a user has enabled OATH
This makes it possible to check from another extension whether the user has strong login security, without depending on internals which can change at any time. (The TwoFactorEnabled hook was intended for something like this but it operates on $wgUser which makes it useless for logins.) Change-Id: Ie15c45c9b29de0a0f926c2467808ca144f05e866
This commit is contained in:
parent
cd72757e4d
commit
160daf2c05
|
@ -6,6 +6,16 @@
|
|||
* @ingroup Extensions
|
||||
*/
|
||||
class OATHAuthUtils {
|
||||
/**
|
||||
* Check whether OATH two-factor authentication is enabled for a given user.
|
||||
* This is a stable method that does not change and can be used in other extensions.
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabledFor( User $user ) {
|
||||
$oathUser = OATHAuthHooks::getOATHUserRepository()->findByUser( $user );
|
||||
return $oathUser && $oathUser->getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt an aray of variables to put into the user's session. We use this
|
||||
|
|
Loading…
Reference in a new issue