def login(): login_form = LoginForm() context = { 'login_form': login_form } if login_form.validate_on_submit(): username = login_form.username.data password = login_form.password.data user = getUser(username) if user is not None: if user.check_password(password): user_data = UserData(username, user.password) user_model = UserModel(user_data) login_user(user_model) flash('Bienvenido de nuevo') redirect(url_for('hello')) else: flash('Credenciales incorrectas !!') else: flash('Credenciales incorrectas !!') return redirect(url_for('index')) return render_template('login.html', **context)
def form(): form = LoginForm() if form.validate_on_submit(): flash('Login requested for user {}, remember_me={}'.format( form.username.data, form.remember_me.data)) return redirect(url_for('index')) return render_template('form.html', form=form, title="Login Form")
def login(): # 已登录则返回首页 if g.user is not None and g.user.is_authenticated: return redirect('/index') # POST接受表单数据 form = LoginForm() # validate_on_submit 的作用是表单处理(包括验证)。如果验证不通过,也直接展示GET页面 if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user is None or user == '': flash('找不到该用户') return render_template('login.html', form=form) if user.verify_password(form.password.data): login_user(user, form.remember_me.data) # return redirect(request.args.get('next')) return redirect(url_for('index')) else: flash('账号名或密码错误') return render_template('login.html', form=form) # GET展示登录视图 return render_template('login.html', form=form)
def login(): 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) next_page = request.args.get('next') if user.is_a_lecture: return redirect(next_page) if next_page else redirect( url_for('index')) # elif user.courser_coordinator == '': # return redirect(next_page) if next_page else redirect(url_for('coordinator_update')) elif user.is_a_coordinator: return redirect(next_page) if next_page else redirect( url_for('coordinator')) # elif user.courser_assurance_board == '' : # return redirect(next_page) if next_page else redirect(url_for('assurance_update')) elif user.is_assuranceboard: return redirect(next_page) if next_page else redirect( url_for('moderation_board')) elif user.is_a_staff_support: return redirect(next_page) if next_page else redirect( url_for('staff_support')) else: flash('Login unsuccessful, Please check your Email and Password', 'danger') return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): flash('Your Username is:{} , Remember me:{}'.format( form.username.data, form.remember_me.data)) return redirect('/index') return render_template('login.html', title='Log In', form=form)
def login(): login_form = LoginForm() context = {'login_form': login_form} if login_form.validate_on_submit(): user_name = login_form.user_name.data password = login_form.password.data user_doc = get_user(user_name) if user_doc.to_dict() is not None: password_from_db = user_doc.to_dict()['password'] if password == password_from_db: user_data = UserData(user_name, password) user = UserModel(user_data) login_user(user) redirect(url_for('hello')) else: flash('la información no coincide') else: flash('el usuario no existe') # flash('Nombre de usuario registrado con éxito') #los flashes hay que renderearlos en el html #flash eliminado porque ya no tiene sentido return redirect(url_for('index')) return render_template('login.html', **context)
def login(): login_form = LoginForm() context = {'login_form': login_form} if login_form.validate_on_submit(): username = login_form.username.data password = login_form.password.data user_doc = get_user(username) if user_doc.to_dict() is not None: if check_password_hash(user_doc.to_dict()['password'], password): user_data = UserData(username, password) user = UserModel(user_data) login_user(user) flash('Bienvenido de Nuevo') redirect(url_for('hello')) else: flash('La informacion no coincide') else: flash('El usuario no existe') # flash('Nombre de usuario registrado con éxito') return redirect(url_for('index')) return render_template('login.html', **context)
def signup(): signup_form = LoginForm() context = {'signup_form': signup_form} if signup_form.validate_on_submit(): username = signup_form.username.data password = signup_form.password.data user_doc = get_user(username) if user_doc.to_dict() is None: password_hash = generate_password_hash(password) user_data = UserData(username, password_hash) user_put(user_data) user = UserModel(user_data) login_user(user) flash('Bienvenido!') return redirect(url_for('hello')) else: flash('El usario existe!') return render_template('signup.html', **context)
def logview(): if current_user.is_authenticated: if current_user.type == 'S': return redirect(url_for('stuhome')) else: return redirect(url_for('profhome')) l1 = LoginForm() if l1.validate_on_submit(): user = teach.find_one({"_id": l1.id.data}) if user is not None and l1.password.data == user.get("pword"): t = User(id=user.get("_id"), password=user.get("pword"), type="T") login_user(t, duration=datetime.timedelta(hours=1)) return redirect(url_for('profhome')) elif user is not None: flash('Invalid username/password combination.') else: user = stu.find_one({"_id": l1.id.data}) if user is not None and l1.password.data == user.get("pword"): t = User(id=user.get("_id"), password=user.get("pword"), type="S") login_user(t, duration=datetime.timedelta(hours=1)) return redirect(url_for('stuhome')) else: flash('Invalid username/password combination.') return render_template('login.html', form=l1, title='Log in.', template='login-page', body="Log in with your User account.")
def login(): form = LoginForm() # validate_on_submit : Xu ly moi su kien cho form if form.validate_on_submit(): flash("Yeu cau dang nhap tu user {}, remmember_me {}".format(form.username.data,form.remember_me.data)) return redirect(url_for('index')) return render_template("login.html", title="Sign In", form=form)
def login(): pass form = LoginForm() if(BINGONE__WEB__USER__KEY in session): flash('您已登陆') return index() if request.method == 'POST': # if(form.register.data == True): # flash('欢迎注册校友订阅系统') # return render_template('common/form.html',form=RegisterForm(),) if form.validate_on_submit(): username = form.username.data password = form.password.data user = DAO.getUser(User.username == username) if user != None and user.verify_password(password): session[BINGONE__WEB__USER__KEY] = user.username session[BINGONE__WEB__USERID__KEY] = user.user_id userCache.put(user.username,user.user_id) session.permanent = False if username == ADMIN.username and ADMIN.verify_password(password): session[BINGONE__WEB__ADMIN__KEY] = True return execSuccess('login success') return bad_request(msg='login failed') flash('欢迎登陆校友订阅系统') return defaultRender('common/form.html', form=form,register=True)
def Login(): log = LoginForm() if log.validate_on_submit(): user = User.query.filter_by(email=log.email.data).first() if user and bcrypt.check_password_hash(user.password, log.password.data): return redirect(url_for('home')) return render_template('login.html', title = 'Login', log=log)
def login(): form = LoginForm() if form.validate_on_submit(): flash( 'Login requested for user {}, password: {}, remember_me={}'.format( form.username.data, form.password.data, form.remember_me.data)) return redirect(url_for('index')) return render_template('login.html', title='Sigin In', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user and user.check_password(form.password.data): login_user(user, remember=form.remember.data) return redirect(url_for("view.user_package")) form.errors['username'] = ['用户名或密码错误'] return render_template("login.html", form=form)
def login(): form = LoginForm() if form.validate_on_submit(): flash("Login requestd") return redirect(url_for("index")) return render_template("login.html", form = form)
def login(): form = LoginForm() if form.validate_on_submit(): flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data)) return redirect('/index') return render_template('login.html', title='Sign In', form=form, providers=app.config['OPENID_PROVIDERS'])
def login(): form = LoginForm() if request.method == 'POST': if form.validate_on_submit(): flash("Login successful!") sleep(2) return redirect('/index') return render_template('login.html', title='Login', form=form) else: return render_template('login.html', title='Login', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = (auth(form.username.data, form.password.data)) if user == True: login_user(User(), remember=form.remember.data) return redirect('/index') else: flash('invalid username or password') return render_template('login.html', form=form)
def login(): 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) flash('You have been logged in!', 'success') return redirect(url_for('home')) else: flash('Login Unsuccessful. Please check username and password', 'danger') return render_template('login.html',form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is not None and check_password_hash(user.password, form.password.data): login_user(user) flash('登录成功') return render_template('ok.html', name=form.username.data) else: flash('用户或密码错误') return render_template('login.html', form=form)
def login(): if g.user is not None and g.user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): session['remember_me'] = form.remember_me.data return oid.try_login(form.openid.data, ask_for=['nickname', 'email']) return render_template('login.html', title='Sign In', form=form, providers=app.config['OPENID_PROVIDERS'])
def login(): if current_user.is_authenticated: return redirect("/") form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None or not user.check_password(form.password.data): return redirect('login') login_user(user, remember=form.remember_me.data) flash(f'Login for user {form.username.data} : {form.remember_me.data}') return redirect("/") return render_template("login.html", title='Log In', form=form)
def login(): '''On this function we have post request so we post the information that we got from the field, and if it's valid we will redirect to the home page with a little message that give the username and the length of the password''' form = LoginForm() if form.validate_on_submit(): flash( "Login success for user {} with password of length: {} !".format( form.username.data, len(form.password.data)), 'success') return redirect(url_for('index')) return render_template('login.html', form=form)
def login(): form = LoginForm() form.name.choices = [(r.id, r.name) for r in g.session.query(User).all()] # form.name.choices = ['1', '2', '3'] if form.validate_on_submit(): user = g.session.query(User).filter_by(id=form.name.data).first() if user is not None and user.verify_password(form.password.data): login_user(user, form.remember_me.data) # flash('登录成功') return redirect(request.args.get('next') or url_for('coronavirus.index_view')) flash('Invalid username or password') return render_template('/login.html', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None or not user.check_password(form.password.data): flash('Invalid username or password') return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) return redirect(url_for('index')) return render_template('login.html', title='Sign In', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for("orders.index")) form = LoginForm() if form.validate_on_submit(): empl_number = form.employee_number.data employee = Employee.query.filter( Employee.employee_number == empl_number).first() if not employee or not employee.check_password(form.password.data): return redirect(url_for(".login")) login_user(employee) return redirect(url_for("orders.index")) return render_template("login.html", form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) 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 ) next_page = request.args.get('next') return redirect(next_page) if next_page else redirect(url_for('home')) else : flash(f'LogIn Unsuccessful!','danger') return render_template('login.html',form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) form = LoginForm() user = User.query.filter_by(username=form.username.data).first() if form.validate_on_submit(): if user is None or not user.check_password(form.password.data): flash("Invalid Username or Passowrd") return redirect(url_for('login')) login_user(user) return redirect(url_for('home')) return render_template('login.html', title="Login- Generic", form=form)
def login(): form = LoginForm() if request.method == 'POST': if form.validate_on_submit(): data = form.data user = Admin.query.filter_by(username=data['username']).first() if user.check_pwd(data['password']): session['admin'] = data['username'] if data['remember']: session.permanent = True return redirect(url_for('admin.index')) else: flash('密码错误') return redirect(url_for('admin.login')) return render_template('admin/login.html', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None or not user.check_password(form.password.data): flash('Invalid username or password') return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) #重定向到next页面 next_page = request.args.get('next') if not next_page or url_parse(next_page).netloc != '': next_page = url_for('index') return redirect(next_page) return render_template('login.html', title='Sign In', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('user')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user is None: flash('Invalid username.Please register first.') return redirect(url_for('login')) login_user(user) next_page = request.args.get('next') if not next_page or url_parse(next_page).netloc != '': next_page = url_for('home') # flash('Login requested for user {}'.format(form.username.data)) return redirect(next_page) return render_template('login.html', title='Login', form=form)