mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Simplify Login mechanism code
This commit is contained in:
parent
81ed16603d
commit
05c6f1afa6
@ -1,6 +1,7 @@
|
||||
from datetime import datetime
|
||||
from flask import abort, flash, redirect, render_template, request, url_for
|
||||
from flask_login import current_user, login_user, login_required, logout_user
|
||||
from sqlalchemy import or_
|
||||
from . import bp
|
||||
from .forms import (LoginForm, ResetPasswordForm, ResetPasswordRequestForm,
|
||||
RegistrationForm)
|
||||
@ -33,10 +34,9 @@ def login():
|
||||
return redirect(url_for('main.dashboard'))
|
||||
form = LoginForm(prefix='login-form')
|
||||
if form.validate_on_submit():
|
||||
user = User.query.filter_by(username=form.user.data).first()
|
||||
if user is None:
|
||||
user = User.query.filter_by(email=form.user.data.lower()).first()
|
||||
if user is not None and user.verify_password(form.password.data):
|
||||
user = User.query.filter(or_(User.username == form.user.data,
|
||||
User.email == form.user.data.lower())).first()
|
||||
if user and user.verify_password(form.password.data):
|
||||
login_user(user, form.remember_me.data)
|
||||
next = request.args.get('next')
|
||||
if next is None or not next.startswith('/'):
|
||||
|
Loading…
Reference in New Issue
Block a user