You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/auth/index.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,11 @@ The next step is to link your database and start signing users in.
32
32
33
33
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.
34
34
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:
36
36
37
-
```php
37
+
::: code-group
38
+
39
+
```php [Auth connect]
38
40
auth()->connect([
39
41
'dbtype' => '...',
40
42
'charset' => '...',
@@ -46,16 +48,16 @@ auth()->connect([
46
48
]);
47
49
```
48
50
49
-
If you have an existing PDO connection, you can pass it to Leaf Auth:
50
-
51
-
```php
51
+
```php [Existing PDO instance]
52
52
$db = new PDO('mysql:dbname=test;host=127.0.0.1', 'root', '');
53
53
54
54
auth()->dbConnection($db);
55
55
56
56
// you can use leaf auth the same way you always have
57
57
```
58
58
59
+
:::
60
+
59
61
## Auth + Leaf MVC
60
62
61
63
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
90
92
91
93
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:
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`:
0 commit comments