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
Copy file name to clipboardExpand all lines: src/docs/auth/user.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ After successfully logging in or registering a user, Leaf Auth provides a bunch
6
6
7
7
You can usually get the current user's information using the `data()` method, however, the output is an array of the user's data together with the tokens which is not very convenient for use within your application.
The `user()` method allows you to pick out exactly the information you need from the user's data. If you need all the user's data, you can use the `get()` method:
Picking specific fields also gives you access to fields you may have hidden using the auth config. This is useful because it allows you to perform operations on the user's data without mistakenly exposing hidden fields.
25
25
26
-
```php
26
+
```php:no-line-numbers
27
27
auth()->config('hidden', ['secret_field']);
28
28
29
29
$secretField = auth()->user()->secret_field;
30
30
```
31
31
32
32
While this may seem like a lot of work, it's a good way to ensure that your user's data is secure and only accessible where needed.
33
33
34
-
## Email verification <Badge>NEW</Badge>
34
+
## Email verification
35
35
36
36
Email verification is a very important feature in most applications. It allows you to verify that the email address provided by a user is valid and that they have access to it. Leaf Auth by default does not incorporate email verification into the authentication process, but you can easily add it to your application using handy functions added in Auth v3.4.0.
When a user clicks on the verification link, you first need to verify the token. You can do this using the `verifyToken()` method. This method returns `true` if the token is valid and `false` if the token is invalid.
60
+
When a user clicks on the verification link, you first need to verify the token. You can do this using the `verifyToken()` method. This method returns the user tied to the token if the token is valid and `false` if the token is invalid.
61
61
62
62
```php
63
63
$token = request()->get('token');
64
-
$isValid = auth()->verifyToken($token);
64
+
$userToVerify = auth()->verifyToken($token);
65
65
66
-
if ($isValid) {
66
+
if ($userToVerify) {
67
67
// Token is valid
68
68
} else {
69
69
// Token is invalid
@@ -74,9 +74,9 @@ If the token is valid, you can then update the user's `email_verified_at` column
74
74
75
75
```php
76
76
$token = request()->get('token');
77
-
$isValid = auth()->verifyToken($token);
77
+
$userToVerify = auth()->verifyToken($token);
78
78
79
-
if ($isValid && auth()->user()->verifyEmail()) {
79
+
if ($userToVerify && $userToVerify->verifyEmail()) {
80
80
// Email is verified
81
81
} else {
82
82
// Could not verify email, missing or invalid token
0 commit comments