Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated PR 2110 - Update auth-guard.md #16

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
```