Customize Base Settings
flask_authlib.BaseConfig
- contains core settings of the library.
Default values of this object:
1 2 3 4 5 6 7 8 9 |
|
HOME_URL
- home page URLLOGIN_URL
- login page URLREGISTER_URL
: register page URLLOGOUT_URL
- logout URLLOGIN_MESSAGE_CATEGORY
- login message category ( flash message ), it is required byflask_login
MIN_PASSWORD_LENGTH
- minimum password length, it will be used in registration process.EMAIL_UNIQUE
- if it istrue
, users' email will be validated for uniquennes in the register process.
Customizing Base Config
Basic Application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Import BaseConfig
from flask_authlib
and create a python class that will describe your custom settings:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Settings
There are also some settings that I do not recommend changing: TEMPLATES_FOLDER_NAME
and others that I have not written above.
Let's customize settings:
1 2 3 4 5 |
|
Now, after customizing we can give our settings object as argument( configs are Optional
) to the Auth
class:
1 2 3 4 5 6 7 |
|
- Navigate to
/login
:
- Yeah, we changed the login URL, then we should navigate
/auth/login
:
-
Check register URL:
-
Check password length:
-
Check password length validation:
-
Check register functionality:
-
Check logout URL after login:
HTTP 302
If we navigate /auth/logout
, the built-in logout view clears all sessions and will redirect us to HOME_PAGE
.