Skip to content

Commit

Permalink
Merge pull request tymondesigns#16 from eschricker/doc/update-auth-guard
Browse files Browse the repository at this point in the history
Migrated PR 2110 - Update auth-guard.md
  • Loading branch information
Messhias authored Sep 28, 2021
2 parents 6d9b9f5 + 0f39914 commit 3c14857
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/auth-guard.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ try {

```

If the user is not set, then a `PHPOpenSourceSaver\JWTAuth\Exceptions\UserNotDefinedException` will be thrown
If the user is not set, then a `PHPOpenSourceSaver\JWTAuth\Exceptions\UserNotDefinedException` will be thrown.

### logout()

Expand All @@ -73,7 +73,7 @@ auth()->logout(true);

### refresh()

Refresh a token, which invalidates the current one
Refresh a token, which invalidates the current one.

```php
$newToken = auth()->refresh();
Expand All @@ -85,7 +85,7 @@ $newToken = auth()->refresh(true, true);

### invalidate()

Invalidate the token (add it to the blacklist)
Invalidate the token (add it to the blacklist).

```php
auth()->invalidate();
Expand All @@ -104,7 +104,7 @@ $token = auth()->tokenById(123);

### payload()

Get the raw JWT payload
Get the raw JWT payload.

```php
$payload = auth()->payload();
Expand All @@ -118,7 +118,7 @@ $payload->toArray(); // = ['sub' => 123, 'exp' => 123456, 'jti' => 'asfe4fq434as

### validate()

Validate a user's credentials
Validate a user's credentials.

```php
if (auth()->validate($credentials)) {
Expand Down Expand Up @@ -147,7 +147,8 @@ $user = auth()->setRequest($request)->user();
```

### Override the token ttl
This example sets the token to expire after 2 hours.

```php
$token = auth()->setTTL(7200)->attempt($credentials);
$token = auth()->setTTL(120)->attempt($credentials);
```

0 comments on commit 3c14857

Please sign in to comment.