Controllers
3 years ago
Helpers
3 years ago
SettingsPages
3 years ago
Views
3 years ago
class-help-contact-us.php
3 years ago
class-premium-features.php
3 years ago
class-settings-page.php
3 years ago
class-settingspage.php
3 years ago
class-setup-wizard.php
3 years ago
class-user-listing.php
3 years ago
class-user-notices.php
3 years ago
class-user-profile.php
3 years ago
class-user-registered.php
3 years ago
class-user.php
3 years ago
index.php
5 years ago
class-user-registered.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsible for WP2FA user's grace periods. |
| 4 | * |
| 5 | * @package wp2fa |
| 6 | * @subpackage user-utils |
| 7 | * @copyright 2023 WP White Security |
| 8 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 9 | * @link https://wordpress.org/plugins/wp-2fa/ |
| 10 | */ |
| 11 | |
| 12 | namespace WP2FA\Admin; |
| 13 | |
| 14 | use WP2FA\Admin\Helpers\User_Helper; |
| 15 | |
| 16 | /** |
| 17 | * User_Profile - Class for handling user things such as profile settings and admin list views. |
| 18 | */ |
| 19 | class User_Registered { |
| 20 | |
| 21 | /** |
| 22 | * Apply 2FA Grace period |
| 23 | * |
| 24 | * @param int $user_id User id. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public static function apply_2fa_grace_period( $user_id ) { |
| 29 | if ( User_Helper::is_user_method_in_role_enabled_methods( $user_id ) ) { |
| 30 | return; |
| 31 | } else { |
| 32 | User_Helper::remove_enabled_method_for_user( $user_id ); |
| 33 | User_Helper::remove_global_settings_hash_for_user( $user_id ); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Checks the user on role change. |
| 39 | * |
| 40 | * @param integer $user_id - The ID of the user. |
| 41 | * @param string $role - The user role. |
| 42 | * @param array $old_roles - Old roles for the user. |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | public static function check_user_upon_role_change( $user_id, $role, $old_roles ) { |
| 47 | self::apply_2fa_grace_period( $user_id ); |
| 48 | } |
| 49 | } |
| 50 |