[MediaWiki-commits] [Gerrit] mediawiki...OATHAuth[master]: Provide a stable method for checking whether a user has enab...
jenkins-bot has submitted this change and it was merged. Change subject: Provide a stable method for checking whether a user has enabled OATH .. 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 --- M OATHAuthUtils.php 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: BryanDavis: Looks good to me, but someone else must approve Brian Wolff: Looks good to me, approved jenkins-bot: Verified diff --git a/OATHAuthUtils.php b/OATHAuthUtils.php index 5fcf018..07f2667 100644 --- a/OATHAuthUtils.php +++ b/OATHAuthUtils.php @@ -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 -- To view, visit https://gerrit.wikimedia.org/r/321818 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie15c45c9b29de0a0f926c2467808ca144f05e866 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OATHAuth Gerrit-Branch: master Gerrit-Owner: Gergő Tisza Gerrit-Reviewer: Anomie Gerrit-Reviewer: Brian Wolff Gerrit-Reviewer: BryanDavis Gerrit-Reviewer: Dpatrick Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...OATHAuth[master]: Provide a stable method for checking whether a user has enab...
Gergő Tisza has uploaded a new change for review. https://gerrit.wikimedia.org/r/321818 Change subject: Provide a stable method for checking whether a user has enabled OATH .. 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 --- M OATHAuthUtils.php 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OATHAuth refs/changes/18/321818/1 diff --git a/OATHAuthUtils.php b/OATHAuthUtils.php index 5fcf018..07f2667 100644 --- a/OATHAuthUtils.php +++ b/OATHAuthUtils.php @@ -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 -- To view, visit https://gerrit.wikimedia.org/r/321818 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie15c45c9b29de0a0f926c2467808ca144f05e866 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OATHAuth Gerrit-Branch: master Gerrit-Owner: Gergő Tisza ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits