Setup Authentication
Stackpress provides a built-in authentication system that allows management of user accounts and works closely with sessions and roles & permissions. The session system is based on the JWT standard, which allows you to securely transmit user information between the client and server. The authentication system is designed to be flexible and extensible, allowing you to customize it to fit your project needs.
1. Auth Config
Update the configuration file using the following auth settings.
❐ Copy
The auth config requires the following parameters.
Option | Notes |
---|---|
The base route for the auth pages. This is used to determine the base route for the auth pages. For example, if you set this to , then the signin page will be at . | |
The default roles for new users. For example, if you set this to , then new users will be assigned the role by default. | |
Whether to allow signin with username. If this is set to, then users will be able to signin with their username. | |
Whether to allow signin with email address. If this is set to , then users will be able to signin with their email address. | |
Whether to allow signin with phone number. If this is set to , then users will be able to signin with their phone number. | |
The minimum length of the password. For example, if you set this to , then the password must be at least 8 characters long. | |
The maximum length of the password. For example, if you set this to , then the password must be at most 32 characters long. | |
When this is set to , the password must contain at least one uppercase letter. | |
When this is set to , the password must contain at least one lowercase letter. | |
When this is set to , the password must contain at least one number. | |
When this is set to , the password must contain at least one special character. For example, . | |
2. Auth Pages
Once an auth config is set, the following pages will be available at the base route.
- • Signup:
- • Signin:
- • Signout:
You can override the view templates for these pages like the following code.
❐ Copy
3. Auth Events
You can also programmatically call the auth APIs using the following events.
Event | Parameters | Response |
---|---|---|
| Returns the rows inserted in a Response object format. | |
| If successful, returns session data in a Response object format. | |
<none> | Returns a success object. | |
<none> | Will return an error Response object if the user, is unauthorized to access. | |