Skip to content

Commit 1ec1778

Browse files
committed
fix: patch up verify email docs
1 parent d357aa6 commit 1ec1778

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/docs/auth/user.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ After successfully logging in or registering a user, Leaf Auth provides a bunch
66

77
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.
88

9-
```php
9+
```php:no-line-numbers
1010
$data = auth()->data();
1111
// ['user' => [...], 'accessToken' => '...', 'refreshToken' => '...']
1212
```
1313

1414
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:
1515

16-
```php
16+
```php:no-line-numbers
1717
$user = auth()->user()->get();
1818
1919
// or pick specific fields
@@ -23,15 +23,15 @@ $username = auth()->user()->username;
2323

2424
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.
2525

26-
```php
26+
```php:no-line-numbers
2727
auth()->config('hidden', ['secret_field']);
2828
2929
$secretField = auth()->user()->secret_field;
3030
```
3131

3232
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.
3333

34-
## Email verification <Badge>NEW</Badge>
34+
## Email verification
3535

3636
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.
3737

@@ -57,13 +57,13 @@ $token = auth()->user()->generateVerificationToken(time() + 3600); // 1 hour
5757

5858
### Verifying a user
5959

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 `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.
6161

6262
```php
6363
$token = request()->get('token');
64-
$isValid = auth()->verifyToken($token);
64+
$userToVerify = auth()->verifyToken($token);
6565

66-
if ($isValid) {
66+
if ($userToVerify) {
6767
// Token is valid
6868
} else {
6969
// Token is invalid
@@ -74,9 +74,9 @@ If the token is valid, you can then update the user's `email_verified_at` column
7474

7575
```php
7676
$token = request()->get('token');
77-
$isValid = auth()->verifyToken($token);
77+
$userToVerify = auth()->verifyToken($token);
7878

79-
if ($isValid && auth()->user()->verifyEmail()) {
79+
if ($userToVerify && $userToVerify->verifyEmail()) {
8080
// Email is verified
8181
} else {
8282
// Could not verify email, missing or invalid token

0 commit comments

Comments
 (0)