flask-security

Flask-Security reset password

一世执手 提交于 2019-12-12 01:39:19
问题 I'm trying to use Flask-Security on a project. I've made may search on SO but I just can't find a way to simply implement a the reset password functionality. I just don't understand how to use the flask-security APi in this case. I notice that all the template can be found on their github, I also check the source code but it's like a mystery. If you have some good tips, advice or example on how to implement reset password it would be really kind. Sorry for my bad english 回答1: You need to turn

SMTPServerDisconnected: please run connect() first

 ̄綄美尐妖づ 提交于 2019-12-11 05:05:31
问题 I'm exploring flask and attempting to setup a simple web app with secure registration and sign in. I'm using flask-security to do this. Unfortunately, when I navigate to the send confirmation page I'm getting the error: "smtpserverdisconnected: please run connect() first". Below are the relevant files I've written. run.py drives the entire application. run.py (this is next to the app folder) #!venv/bin/python from app import app app.run(debug = True) Everything below here is in the app folder

Flask Security: Customize Email Templates

只谈情不闲聊 提交于 2019-12-11 04:13:42
问题 How do you customize the email templates used in flask security without altering the source code? Everything else I have needed such as web templates and email subjects are configurable as defined in the configuration: https://pythonhosted.org/Flask-Security/configuration.html SOLVED: Create a directory templates/security/email Copy all the email templates into this folder and you can edit them. 回答1: SOLVED: Create a directory templates/security/email Copy all the email templates into this

Flask-Security override register view

≯℡__Kan透↙ 提交于 2019-12-10 19:15:11
问题 Is there some convenient way to override register view in Flask-Security? I'm pretty happy with the built-in view for registration, but I need it to be accessible only after authentication and by certain roles. I tried to override it like this (with SECURITY_REGISTER_URL='/register/' ) but that just takes the built-in function and mine is completely ignored: @app.route('/register/') @login_required @roles_required('superuser') def register(): """View function which handles a registration

How to customize registration provided by Flask-security?

风流意气都作罢 提交于 2019-12-10 11:19:38
问题 What am i supposed to do, if need to set up Role of user to, for example FooUser ? Where i need to do this? In my own /create_account view or in context processor? @app.route('/create_account') def create_account(): user_datastore.find_or_create_role('FooUser') user_datastore.add_role_to_user(user,role) return render_template('register_user.html') 回答1: You may customize views following these instructions: http://flask-security.readthedocs.org/en/latest/customizing.html And you may hook into

How to run custom code at login with flask-security

元气小坏坏 提交于 2019-12-10 03:07:03
问题 I am new to flask, but moderately proficient in python - I have a flask app that uses flask-security for user authentication. I would like to add some additional functionality to the user login process. Specifically, I need to save the user's auth_token (which I have set up to be a one-time-use token) to the db when they login, and remove it when they log out. The issue comes because flask-security does not (to my knowledge) expose the machinery of logging in directly to the developer. As far

Flask-security and Bootstrap

拈花ヽ惹草 提交于 2019-12-07 07:47:50
问题 How can I style my Flask-security login site with Bootstrap? The html form looks like this: <form action="{{ url_for_security('login') }}" method="POST" name="login_form"> {{ login_user_form.hidden_tag() }} {{ render_field_with_errors(login_user_form.email) }} {{ render_field_with_errors(login_user_form.password) }} {{ render_field_with_errors(login_user_form.remember) }} {{ render_field(login_user_form.next) }} {{ render_field(login_user_form.submit) }} </form> Bootstrap is implemented, but

Unique Salt per User using Flask-Security

☆樱花仙子☆ 提交于 2019-12-07 02:18:15
问题 After reading here a bit about salting passwords, it seems that it's best to use a unique salt for each user. I'm working on implementing Flask-Security atm, and from the documentation it appears you can only set a global salt: ie SECURITY_PASSWORD_SALT = 'thesalt' Question: How would one go about making a unique salt for each password? Thanks! edit: from the docs on Flask-Security, I found this, which seems to again suggest that this module only uses a single salt for all passwords out of

How to customize registration provided by Flask-security?

折月煮酒 提交于 2019-12-06 10:35:44
What am i supposed to do, if need to set up Role of user to, for example FooUser ? Where i need to do this? In my own /create_account view or in context processor? @app.route('/create_account') def create_account(): user_datastore.find_or_create_role('FooUser') user_datastore.add_role_to_user(user,role) return render_template('register_user.html') You may customize views following these instructions: http://flask-security.readthedocs.org/en/latest/customizing.html And you may hook into the user registration process using signals: http://flask-security.readthedocs.org/en/latest/api.html#signals

Flask-security and Bootstrap

最后都变了- 提交于 2019-12-05 08:55:53
How can I style my Flask-security login site with Bootstrap? The html form looks like this: <form action="{{ url_for_security('login') }}" method="POST" name="login_form"> {{ login_user_form.hidden_tag() }} {{ render_field_with_errors(login_user_form.email) }} {{ render_field_with_errors(login_user_form.password) }} {{ render_field_with_errors(login_user_form.remember) }} {{ render_field(login_user_form.next) }} {{ render_field(login_user_form.submit) }} </form> Bootstrap is implemented, but I dont know how to edit the fields and the submit button.. The render_field_* functions accepts a class