gpt4 book ai didi

python - 如何自定义Flask-security提供的注册?

转载 作者:行者123 更新时间:2023-11-28 21:19:03 26 4
gpt4 key购买 nike

如果需要将用户角色设置为 FooUser,我应该怎么做?我需要在哪里做这个?在我自己的 /create_account View 中还是在上下文处理器中?

@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')

最佳答案

您可以按照以下说明自定义 View : http://flask-security.readthedocs.org/en/latest/customizing.html

您可以使用信号连接到用户注册过程: http://flask-security.readthedocs.org/en/latest/api.html#signals

关于python - 如何自定义Flask-security提供的注册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25376647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com