Esempio n. 1
0
 def post(self):
     form = SigninForm(request.form)
     print("value of form.validate:::::", form.validate())
     if form.validate() == False:
         return render_template('signin.html')
     else:
         user = User.query.filter_by(username=form.username.data)
         login_user(user.one())
         flash('Welcome back {0}'.format(form.username.data))
         print("@@@@@@@@@@@@Login successfully!!!!!")
         return redirect(url_for('index'))
Esempio n. 2
0
def signin():
	form = SigninForm()

	if request.method == 'POST':
		if form.validate() == False:
			return "false"
		else:
			session['email'] = form.email.data
			return "true" #redirect(url_for('profile'))	     
	elif request.method == 'GET':
		return render_template('signin.html', form=form)
Esempio n. 3
0
 def post(self):
     form = SigninForm(request.form)
     print("value of form.validate:::::", form.validate())
     if form.validate() == False:
         return render_template("signin.html")
     else:
         user = User.query.filter_by(username=form.username.data)
         login_user(user.one())
         flash("Welcome back {0}".format(form.username.data))
         print("@@@@@@@@@@@@Login successfully!!!!!")
         return redirect(url_for("index"))
Esempio n. 4
0
def signin():
    if current_user.is_authenticated:
        return redirect(url_for('index', group=g.group[0]))
    form = SigninForm()
    if form.validate_on_submit():
        user = db.session.query(User).filter_by(email=form.email.data).first()
        if user and user.check_password(form.passwd.data):
            login_user(user, remember=form.remember.data)
            theme = db.session.query(Config.theme).filter_by(
                uid=current_user.id).first()[0]
            response = make_response(
                redirect(url_for('index', group=g.group[0])))
            response.set_cookie('theme', value=theme, max_age=9999999999)
            return response
        flash('账号或密码错误', 'danger')
    return render_template('signin.html', form=form, signin_active="active")