Skip to content

Commit d0ff77e

Browse files
committed
✨ Tidy auth config
1 parent bef1ce8 commit d0ff77e

File tree

2 files changed

+137
-20
lines changed

2 files changed

+137
-20
lines changed

Config/auth.php

Lines changed: 125 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,150 @@
33
use Leaf\Helpers\Password;
44

55
return [
6-
// automatically add created_at/updated_at timestamps?
6+
/*
7+
|--------------------------------------------------------------------------
8+
| Generate timestamps
9+
|--------------------------------------------------------------------------
10+
|
11+
| Automatically generate created_at/updated_at timestamps for register
12+
| and update methods
13+
|
14+
*/
715
"USE_TIMESTAMPS" => true,
8-
// Password encode is run when leaf wants to encode passwords on register
9-
// This exact method is used by default in Leaf, so you can delete it if
10-
// you want to.
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Encode password
20+
|--------------------------------------------------------------------------
21+
|
22+
| Password encode is run when leaf wants to encode passwords on register
23+
| This exact method is used by default in Leaf, so you can delete it if
24+
| you want to.
25+
|
26+
*/
1127
"PASSWORD_ENCODE" => function ($password) {
1228
return Password::hash($password);
1329
},
14-
// this function is run to verify the password. It's done by default,
15-
// so you can remove/set this and the above lines null if you wish to.
30+
31+
/*
32+
|--------------------------------------------------------------------------
33+
| Verify Password
34+
|--------------------------------------------------------------------------
35+
|
36+
| this function is run to verify the password. It's done by default,
37+
| so you can remove/set this and the above lines null if you wish to.
38+
|
39+
*/
1640
"PASSWORD_VERIFY" => function ($password, $hashedPassword) {
1741
// Inside the password_verify method, you have access to the password and the hashed password
1842
return Password::verify($password, $hashedPassword);
1943
},
20-
// the default password key
44+
45+
/*
46+
|--------------------------------------------------------------------------
47+
| Password Key
48+
|--------------------------------------------------------------------------
49+
|
50+
| the default password key
51+
|
52+
*/
2153
"PASSWORD_KEY" => "password",
22-
// Hide id field from user object?
54+
55+
/*
56+
|--------------------------------------------------------------------------
57+
| Hide id
58+
|--------------------------------------------------------------------------
59+
|
60+
| Hide id field from user object?
61+
|
62+
*/
2363
"HIDE_ID" => true,
24-
// Hide password field from user object?
64+
65+
/*
66+
|--------------------------------------------------------------------------
67+
| Hide password
68+
|--------------------------------------------------------------------------
69+
|
70+
| Hide user password field
71+
|
72+
*/
2573
"HIDE_PASSWORD" => true,
26-
// Login params error
74+
75+
/*
76+
|--------------------------------------------------------------------------
77+
| Login params error
78+
|
79+
*/
2780
"LOGIN_PARAMS_ERROR" => "Username not registered!",
28-
// Login password error
81+
82+
/*
83+
|--------------------------------------------------------------------------
84+
| Login password error
85+
|
86+
*/
2987
"LOGIN_PASSWORD_ERROR" => "Password is incorrect!",
30-
// USE_SESSION is experimental!!!
31-
// If you encounter any problems using any new auth session features,
32-
// revert to the default auth and manage sessions manually.
33-
// Don't forget to open an issue.
88+
89+
/*
90+
|--------------------------------------------------------------------------
91+
| Use session [EXPERIMENTAL]
92+
|--------------------------------------------------------------------------
93+
|
94+
| Use session based authentication instead of the default JWT based auth.
95+
|
96+
| If you encounter any problems using any new auth session features,
97+
| revert to the default auth and manage sessions manually.
98+
| Don't forget to open an issue.
99+
|
100+
*/
34101
"USE_SESSION" => false,
102+
103+
/*
104+
|--------------------------------------------------------------------------
105+
| Template Engine [EXPERIMENTAL]
106+
|--------------------------------------------------------------------------
107+
|
108+
| Leaf MVC unlike other frameworks tries to give you as much control as
109+
| you need. As such, you can decide which view engine to use.
110+
|
111+
*/
35112
// Create a session on registration?
36113
"SESSION_ON_REGISTER" => false,
37-
// Login page
114+
115+
/*
116+
|--------------------------------------------------------------------------
117+
| Login page route
118+
|
119+
*/
38120
"GUARD_LOGIN" => "/auth/login",
39-
// Register page
121+
122+
/*
123+
|--------------------------------------------------------------------------
124+
| Rehgister page route
125+
|
126+
*/
40127
"GUARD_REGISTER" => "/auth/register",
41-
// Logout route
128+
129+
/*
130+
|--------------------------------------------------------------------------
131+
| Logout route
132+
|
133+
*/
42134
"GUARD_LOGOUT" => "/auth/logout",
43-
// Home page
135+
136+
/*
137+
|--------------------------------------------------------------------------
138+
| Home page route
139+
|
140+
*/
44141
"GUARD_HOME" => "/home",
45-
// Add an auth token to the auth session?
142+
143+
/*
144+
|--------------------------------------------------------------------------
145+
| JWT + Session
146+
|--------------------------------------------------------------------------
147+
|
148+
| Add an auth token to the auth session?
149+
|
150+
*/
46151
"SAVE_SESSION_JWT" => false,
47152
];

Config/paths.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22

33
return [
44
"controllers_path" => "App/Controllers",
5+
56
"models_path" => "App/Models",
7+
68
"migrations_path" => "App/Database/Migrations",
9+
710
"seeds_path" => "App/Database/Seeds",
11+
812
"factories_path" => "App/Database/Factories",
13+
914
"helpers_path" => "App/Helpers",
15+
1016
"views_path" => "App/Views",
17+
1118
"config_path" => "App/Config",
19+
1220
"storage_path" => "App/storage",
21+
1322
"commands_path" => "App/Console",
23+
1424
"routes_path" => "App/Routes",
25+
1526
"lib_path" => "Lib",
27+
1628
"public_path" => "public",
1729
];

0 commit comments

Comments
 (0)