Skip to content

Commit 36b914b

Browse files
committed
feat: update leaf mvc auth docs
1 parent 2cc9bf4 commit 36b914b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/docs/auth/index.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ The next step is to link your database and start signing users in.
3232

3333
To do any kind of authentication, you need to connect to some kind of database which will store your users' data. If you are already using Leaf DB or Leaf MVC, then your database connection will automatically be used by Leaf Auth, so you don't need to connect to your database again.
3434

35-
If you are not using Leaf DB or Leaf MVC, you can connect to your database manually:
35+
If you are **NOT** using Leaf DB or Leaf MVC, you can connect to your database manually:
3636

37-
```php
37+
::: code-group
38+
39+
```php [Auth connect]
3840
auth()->connect([
3941
'dbtype' => '...',
4042
'charset' => '...',
@@ -46,16 +48,16 @@ auth()->connect([
4648
]);
4749
```
4850

49-
If you have an existing PDO connection, you can pass it to Leaf Auth:
50-
51-
```php
51+
```php [Existing PDO instance]
5252
$db = new PDO('mysql:dbname=test;host=127.0.0.1', 'root', '');
5353

5454
auth()->dbConnection($db);
5555

5656
// you can use leaf auth the same way you always have
5757
```
5858

59+
:::
60+
5961
## Auth + Leaf MVC
6062

6163
If you are using Leaf MVC, you can set up Leaf Auth to work with your default database connection by heading over to the `public/index.php` file and uncommenting the line that connects to the database:
@@ -90,12 +92,26 @@ Leaf Auth doesn't give you any structure for your database, with that, you can s
9092

9193
1. By default, Leaf Auth assumes that your database primary key is `id`. If you have a database where you are using another field, say `admin_id` as the primary key, you will need to tell Leaf the name of your primary key. You can do this using the `id.key` config:
9294

93-
```php:no-line-numbers
95+
::: code-group
96+
97+
```php:no-line-numbers [Leaf]
9498
auth()->config('id.key', 'admin_id');
9599
```
96100
101+
```php:no-line-numbers [Leaf MVC - config/auth.php]
102+
'id.key' => 'admin_id'
103+
```
104+
97105
2. Leaf Auth assumes that you will save your users in a database table named `users`, this might however not be the case for your application. If you want to use a different table, you can configure Leaf Auth using `db.table`:
98106
99-
```php:no-line-numbers
107+
::: code-group
108+
109+
```php:no-line-numbers [Leaf]
100110
auth()->config('db.table', 'admins');
101111
```
112+
113+
```php:no-line-numbers [Leaf MVC - config/auth.php]
114+
'db.table' => 'admins'
115+
```
116+
117+
:::

0 commit comments

Comments
 (0)