5

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?

davidism
  • 121,510
  • 29
  • 395
  • 339
Alexander
  • 833
  • 2
  • 8
  • 17

1 Answers1

7

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.

davidism
  • 121,510
  • 29
  • 395
  • 339