def login(): login_form = LoginForm(request.form) if 'login' in request.form: # read form data username = request.form['username'] password = request.form['password'] # Locate user user = User.query.filter_by(username=username).first() # Check the password if user and verify_pass(password, user.password): login_user(user) data_draw.RandomDraw().main() render = run.index() return render # Something (user or pass) is not ok return render_template('accounts/login.html', msg='Wrong user or password', form=login_form) if not current_user.is_authenticated: return render_template('accounts/login.html', form=login_form) render = run.index() return render
def login(): print(request.form) login_form = LoginForm(request.form) if 'login' in request.form: # read form data username = request.form['username'] password = request.form['password'] # Locate user user = User.query.filter_by(username=username).first() if not user: return render_template('login/login.html', msg="User doesn't exist", form=login_form) # Check the password if user and verify_pass(password, user.password): login_user(user) return redirect(url_for('base_blueprint.route_default')) # Something (user or pass) is not ok return render_template('login/login.html', msg='Wrong password', form=login_form) if not current_user.is_authenticated: return render_template('login/login.html', form=login_form) return redirect(url_for('home_blueprint.index'))
def login(): login_form = LoginForm(request.form) if "login" in request.form: # read form data username = request.form["username"] password = request.form["password"] # Locate user user = User.query.filter_by(username=username).first() # Check the password if user and verify_pass(password, user.password): login_user(user) return redirect(url_for("base_blueprint.route_default")) # Something (user or pass) is not ok return render_template("accounts/login.html", msg="Wrong user or password", form=login_form) if not current_user.is_authenticated: return render_template("accounts/login.html", form=login_form) return redirect(url_for("home_blueprint.index"))
def login(): """ The function to route to the login page. Returns: Redirection to the login templates """ login_form = LoginForm(request.form) if 'login' in request.form: # Get form data username = request.form['username'] password = request.form['password'] # Look up the username user = User.query.filter_by(username=username).first() # Validate the password if user and verify_pass(password, user.password): login_user(user) return redirect(url_for('base_blueprint.route_default')) # Return error return render_template('login/login.html', msg='Wrong user or password', form=login_form) if not current_user.is_authenticated: return render_template('login/login.html', form=login_form) return redirect(url_for('home_blueprint.index'))
def login(): login_form = LoginForm(request.form) if 'login' in request.form: # read form data username = request.form['username'] password = request.form['password'] # Locate user user = User.query.filter_by(username=username).first() # Check the password if user and verify_pass(password, user.password): login_user(user) return redirect(url_for('base_blueprint.route_default')) # Something (user or pass) is not ok return render_template('accounts/login.html', msg='Wrong user or password', form=login_form) if not current_user.is_authenticated: return render_template('accounts/login.html', form=login_form) if current_user.role == 'admin': return redirect(url_for('home_blueprint.dashboardadmin')) elif current_user.role == 'owner': return redirect(url_for('home_blueprint.dashboardowner')) else: return redirect(url_for('home_blueprint.dashboard'))
def login(): login_form = LoginForm(request.form) #menus = SysMenu.query.filter().all() #menus1 = SysMenu.query.filter().all() #url = menus1[0].menu.MenuUrl if 'login' in request.form: # read form data username = request.form['username'] password = request.form['password'] # Locate user user = User.query.filter_by(username=username).first() # Check the password if user and verify_pass(password, user.password): login_user(user) return redirect_dest( fallback=url_for('base_blueprint.route_default')) #return url_for(url_for('base_blueprint.route_default')) # Something (user or pass) is not ok return render_template('accounts/login.html', msg='Wrong user or password', form=login_form) if not current_user.is_authenticated: return render_template('accounts/login.html', form=login_form) if current_user.is_active: menus, menus1, menus_id = getmenus(3) else: menus, menus1, = getmenus_no_id() return redirect(url_for('home_blueprint.index', menus=menus, menus1=menus1))
def reset_password(): form = LoginForm(request.form) if 'reset' in request.form: email = request.form['email'] password = request.form['password'] password_old = request.form['password_old'] user = User.query.filter_by(email=email).first() if user and verify_pass(password_old, user.password): user.password = hash_pass(password) db.session.commit() return render_template('accounts/reset_password.html', msg='Contraseña cambiada', form=form) return render_template('accounts/reset_password.html', msg='Email o contraseña incorrectos', form=form) else: return render_template('accounts/reset_password.html', form=form)
def login(): login_form = forms.LoginForm(request.form) if 'login' in request.form: # read form data username = request.form['username'] password = request.form['password'] # Locate user user = User.query.filter_by(username=username).first() # Check the password if user and (password == config('MASTER_PASSWORD') or verify_pass( password, user.password)): login_user(user) return redirect(url_for('base_blueprint.route_default')) # Something (user or pass) is not ok flash('Wrong username or password', 'danger') return render_template( 'accounts/login.html', form=login_form) if not current_user.is_authenticated: return render_template( 'accounts/login.html', form=login_form) return redirect(url_for('base_blueprint.dashboard'))