Add User::requiresMultifactor()
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jan 2021 13:58:12 +0000 (14:58 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 26 Jan 2021 14:15:28 +0000 (15:15 +0100)
wcfsetup/install/files/lib/data/user/User.class.php

index 314d8e4fb5556376436ec54d297f930519d34a30..1c2cb61de8f4f690848048e397fa062cd28ac0aa 100644 (file)
@@ -747,6 +747,21 @@ final class User extends DatabaseObject implements IPopoverObject, IRouteControl
         return REGISTER_ACTIVATION_METHOD & self::REGISTER_ACTIVATION_USER;
     }
 
+    /**
+     * Returns true if the user is a member of a user group that requires
+     * multi-factor authentication to be enabled.
+     */
+    public function requiresMultifactor(): bool
+    {
+        foreach (UserGroup::getGroupsByIDs($this->getGroupIDs()) as $group) {
+            if ($group->requireMultifactor) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     /**
      * @inheritDoc
      */