Skip to content

Commit 83ba60d

Browse files
committed
feat: add auth find docs
1 parent b6fa2e2 commit 83ba60d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/docs/auth/login.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,28 @@ Everything after this point is the same as signing up a user normally.
163163
::: info OAuth Token
164164
The `fromOAuth()` method expects an OAuth token to be passed in. This token is usually gotten from the OAuth provider you are using. You can later use this token to make requests to the OAuth provider on behalf of the user. Leaf Auth saves this token so you can retrieve it later using the `auth()->oauthToken()` method.
165165

166-
```php
166+
```php:no-line-numbers
167167
$token = auth()->oauthToken();
168168
```
169169

170170
:::
171171

172+
## Finding a user by id <Badge type="tip" text="New" />
173+
174+
There are times when you might want to find a user by their id to perform some operations on them while they are NOT logged in. For instance, finding a user by their id to assign a role to them. Leaf Auth provides the `find()` method to do this:
175+
176+
```php
177+
$user = auth()->find(1);
178+
179+
...
180+
181+
$user->assign('admin');
182+
183+
...
184+
185+
$user->transactions()->create([...]);
186+
```
187+
172188
## Auth with no password
173189

174190
Leaf Auth usually expects a password field to authenticate users. This is necessary because most applications require a password to authenticate users. The field is usually named `password`, however, you can configure Leaf Auth to expect a different field:

0 commit comments

Comments
 (0)