def login(): form = LoginForm() if form.validate_on_submit(): user=Usuarios.query.filter_by(username=form.username.data).first() if user!=None and user.verify_password(form.password.data): login_user(user) return redirect(url_for('inicio')) form.username.errors.append("Usuario o contraseña incorrectas.") return render_template('login.html', form=form)
def login(): from aplicacion.models import Usuarios from aplicacion.login import login_user, is_login # Control de permisos if is_login(): return redirect(url_for("inicio")) form = LoginForm() if form.validate_on_submit(): user = Usuarios.query.filter_by(username=form.username.data).first() if user is not None and user.verify_password(form.password.data): login_user(user) return redirect(url_for('inicio')) form.username.errors.append("Usuario o contraseña incorrectas.") return render_template('login.html', form=form)
def login(): # Control de permisos if current_user.is_authenticated: return redirect(url_for("inicio")) form = LoginForm() if form.validate_on_submit(): user = Usuarios.query.filter_by(username=form.username.data).first() if user != None and user.verify_password(form.password.data): login_user(user) next = request.args.get('next') return redirect(next or url_for('inicio')) form.username.errors.append("Usuario o contraseña incorrectas.") return render_template('login.html', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('main')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) return redirect(url_for('main')) else: flash('Loggin unsuccesful. Please check you username and password', 'danger') return render_template('login.html', form=form)