Flask-security login and logout Flask-security login and logout flask flask

Flask-security login and logout


Flask-Security uses Flask-Login. So you can do the following as per documentation:

login_user(user) # where user is your user objectlogout_user()

Obviously, you still need to write your views where you will validate the form submissions etc before calling these methods and do the proper template rendering or redirects as needed.


Go to the flask security configurations page here: http://pythonhosted.org/Flask-Security/configuration.htmland copy over all the default configuration values into your init.py file like:

app.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'security/login_user.html'

etc...

Then you have to download the security file which contains all the html templates. Put that folder in your templates folder where you keep all the other html templates. You can use google to figure out where to download the folder as well as how to set up the rest of flask security. I had a lot of trouble figuring out flask security as well, but after poking around here and on google, I was able to get some of it working, so don't lose faith. Hope this helps.