You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on the scope of your application, there may be times when you'll decide that it is absolutely necessary to force user(s) to reset their password. This practice is common when you find out that users of your application do not use strong passwords OR there is a reasonable suspicion that their passwords have been compromised. This guide provides you with ways to achieve this.
-[Check if a User Requires Password Reset](#check-if-a-user-requires-password-reset)
8
+
-[Force Password Reset On a User](#force-password-reset-on-a-user)
9
+
-[Removing Password Reset Flag On a User](#removing-password-reset-flag-on-a-user)
10
+
-[Force Password Reset On Multiple Users](#force-password-reset-on-multiple-users)
11
+
-[Force Password Reset On All Users](#force-password-reset-on-all-users)
12
+
13
+
## Available Methods
14
+
15
+
Shield provides a way to enforce password resets throughout your application. The `Resettable` trait on the `User` entity and the `UserIdentityModel` provides the following methods to do so.
16
+
17
+
### Check if a User Requires Password Reset
18
+
19
+
When you need to check if a user requires password reset, you can do so using the `requiresPasswordReset()` method on the `User` entity. Returns boolean `true`/`false`.
20
+
21
+
```php
22
+
if ($user->requiresPasswordReset()) {
23
+
//...
24
+
}
25
+
```
26
+
27
+
### Force Password Reset On a User
28
+
29
+
To force password reset on a user, you can do so using the `forcePasswordReset()` method on the `User` entity. Returns boolean `true`/`false`.
30
+
31
+
```php
32
+
$user->forcePasswordReset();
33
+
```
34
+
35
+
### Remove Force Password Reset Flag On a User
36
+
37
+
Undoing or removing the force password reset flag on a user can be done using the `undoForcePasswordReset()` method on the `User` entity. Returns boolean `true`/`false`.
38
+
39
+
```php
40
+
$user->undoForcePasswordReset();
41
+
```
42
+
43
+
### Force Password Reset On Multiple Users
44
+
45
+
If you see the need to force password reset for more than one user, the `forceMultiplePasswordReset()` method of the `UserIdentityModel` allows you to do this easily. It accepts an `Array` of user IDs.
If you suspect a security breach or compromise in the passwords of your users, you can easily force password reset on all the users of your application using the `forceGlobalPasswordReset()` method of the `UserIdentityModel`.
Shield provides a way to enforce password resets throughout your application. The `Resettable` trait on the `User` entity provides the following utility methods to do so.
325
-
326
-
#### requiresPasswordReset()
327
-
328
-
Allows you to check if a user requires password reset. Returns boolean `true`/`false`.
329
-
330
-
```php
331
-
if ($user->requiresPasswordReset()) {
332
-
//...
333
-
}
334
-
```
335
-
336
-
#### forcePasswordReset()
337
-
338
-
Allows you to force password reset on a user. Returns boolean `true`/`false`.
339
-
340
-
```php
341
-
$user->forcePasswordReset();
342
-
```
343
-
344
-
#### undoForcePasswordReset()
345
-
346
-
Allows you to undo or remove the force password reset flag on a user. Returns boolean `true`/`false`.
347
-
348
-
```php
349
-
$user->undoForcePasswordReset();
350
-
```
351
-
352
-
There are times when you might want to force password reset on multiple users or for all users in your application, maybe due to security breach. The `UserIdentityModel` provides methods to do this easily.
353
-
354
-
#### forceMultiplePasswordReset()
355
-
356
-
This allows you to force password reset for multiple users. Accepts an array of user IDs.
0 commit comments