mirror of
https://github.com/wassname/flask-security.git
synced 2026-09-11 12:11:25 +08:00
Add login to security blueprint
This commit is contained in:
@@ -93,6 +93,12 @@ def authenticate():
|
||||
return redirect(request.referrer or _security.login_manager.login_view)
|
||||
|
||||
|
||||
def login():
|
||||
form = PasswordlessLoginForm() if _security.passwordless else LoginForm()
|
||||
template = 'send_login' if _security.passwordless else 'login'
|
||||
return render_template('security/%s.html' % template, login_form=form)
|
||||
|
||||
|
||||
def logout():
|
||||
"""View function which handles a logout request."""
|
||||
|
||||
@@ -288,6 +294,9 @@ def create_blueprint(app, name, import_name, **kwargs):
|
||||
methods=['POST'],
|
||||
endpoint='authenticate')(authenticate)
|
||||
|
||||
bp.route(config_value('LOGIN_URL', app=app),
|
||||
endpoint='login')(login)
|
||||
|
||||
bp.route(config_value('LOGOUT_URL', app=app),
|
||||
endpoint='logout')(login_required(logout))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user