Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Flask-Security to change password in code

I want to create a page to edit some user data, including the password. How can I change the password in my own view with Flask-Security?

like image 744
Alexander Avatar asked May 16 '16 07:05

Alexander


1 Answers

Use hash_password to hash the password with Flask-Security.

from flask_security.utils import hash_password
user.password = hash_password('Stack Overflow')

Unless you have a good reason not to, you should use the built-in change password view and form. Flask-Security offers the ability to customize both. Leaving the change password form in its own page is a common pattern.

like image 171
davidism Avatar answered Oct 06 '22 14:10

davidism