Configuration
Auth7 can be configured using the init() function.
Example
auth7.init({
mongoURI: "mongodb://localhost:27017/auth7",
jwtSecret: "secret",
accessTokenExpiry: "15m",
refreshTokenExpiry: "7d",
cookieSecure: false,
});
Configuration Options
| Option | Description |
|---|---|
| mongoURI | MongoDB connection string |
| jwtSecret | Secret used for JWT |
| accessTokenExpiry | Access token expiry time |
| refreshTokenExpiry | Refresh token expiry |
| cookieSecure | Enable secure cookies |
Custom User Fields
You can extend the user schema.
auth7.init({
userFields: {
username: String,
role: String,
},
});
This allows storing additional user information.