def login(): form = UserLoginForm() user = User() if request.method == 'POST' and form.validate_on_submit(): request_data = { 'email': form.email.data, 'password': form.password.data } error, user_data = user.login(request_data) if error is None and user_data['email_confirmed']: del user_data['_id'] del user_data['password'] session.clear() for key in user_data: session[key] = user_data[key] return redirect(url_for('main.attend')) elif error is None and not user_data['email_confirmed']: return redirect(url_for('main.unconfirmed')) else: flash(error) return make_response(render_template('user/login.html', form=form), 400) elif request.method == 'POST' and not form.validate_on_submit(): return make_response(render_template('user/login.html', form=form), 400) return render_template('user/login.html', form=form)
def UserLogin(): form = UserLoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and user.role == "user": login_user(user) return redirect(url_for("UserDashboard")) else : flash("invalid login") return render_template("auth/login.html",form=form)
def UserLogin(): form = UserLoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user : if check_password_hash(user.password,form.password.data): login_user(user) flash("Anda berhasil masuk","success") return redirect(url_for("AdminDashboard")) flash("Email atau Password salah","danger") return render_template("user/login.html",form=form)
def UserLogin(): form = UserLoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user: if check_password_hash(user.password, form.password.data): login_user(user) flash("Loggin success", "success") return redirect(url_for("UserDashboard")) flash("Invalid login", "danger") return render_template("user/login.html", form=form) return render_template("user/login.html", form=form)
def login(): form = UserLoginForm() if request.method == 'POST' and form.validate_on_submit(): request_data = {'email':form.email.data, 'password':form.password.data} error, user_data = post_login(request_data) if error is None: del user_data['_id'] del user_data['password'] session.clear() for key in user_data: session[key] = user_data[key] return redirect(url_for('main.index')) flash(error) return render_template('account/login.html', form=form)
def post(self): form = UserLoginForm(request.form) context = { 'form': form, 'error': None } if form.validate_on_submit(): user = form.validate_login() if user: login_user(user) return redirect(url_for('user.home')) else: #context['error'] = 'Invalid Username / Password.' error = 'Invalid Username / Password.' return render_template('login.html', **context)
def login(): form = UserLoginForm(request.form) if request.method == "POST" and form.validate(): st_id = form.st_id.data hashed = dbHandler.retrieveUsers(str(st_id)) m = str(form.password.data) opassword = hashlib.md5(m.encode()) hpassword = opassword.hexdigest() if str(hpassword) == str(hashed): session['logged_in'] = True return redirect(url_for('home')) else: return ('error in matching the password') else: return render_template("login.html", form=form)