本文整理汇总了Python中forms.SigninForm.validate方法的典型用法代码示例。如果您正苦于以下问题:Python SigninForm.validate方法的具体用法?Python SigninForm.validate怎么用?Python SigninForm.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.SigninForm
的用法示例。
在下文中一共展示了SigninForm.validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
"""
Routing to signin.html
Returns:
POSTS:
Signin.html: when form not valid
Admin_dashboard: When form valid.
sets cookies with email, accessLvl
GET:
Signin.html
"""
form = SigninForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form=form)
else:
user = User.query.filter_by(email=form.email.data).first()
session['email'] = form.email.data
session['accessLvl'] = user.accessLvl
return redirect(url_for('admin_dashboard'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例2: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if "email" in session:
return redirect(url_for("welcome", form=form))
if request.method == "POST":
if form.validate() == False:
return render_template("signin.html", form=form)
else:
session["email"] = form.email.data
signin = User.query.filter_by(email=session["email"]).first()
if signin:
session["lastname"] = db_session.query(User.lastname).filter(User.email == session["email"]).first()
session["firstname"] = db_session.query(User.firstname).filter(User.email == session["email"]).first()
session["phone"] = db_session.query(User.phone).filter(User.email == session["email"]).first()
session["country_id"] = db_session.query(User.country_id).filter(User.email == session["email"]).first()
session["lastname"] = session["lastname"]
session["firstname"] = session["firstname"]
session["phone"] = session["phone"]
session["country_id"] = session["country_id"]
if session["country_id"] == db_session.query(User.country_id).filter(User.country_id == 1).first():
session["country_id"] == "Nigerian"
else:
session["country_id"] == "Foreigner"
return redirect(url_for("welcome", form=form))
elif request.method == "GET":
return render_template("signin.html", form=form)
示例3: sign_in
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def sign_in():
form = SigninForm(request.form)
if request.method == 'POST' and form.validate():
session["sign_in"] = True
session["username"] = form.username.data
flash("Hello {user}!".format(user=session["username"]))
return redirect(url_for('index'))
return render_template('sign_in.html', form=form)
示例4: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form=form)
else:
session['email'] = form.email.data
return redirect(url_for('profile'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例5: login
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def login():
form=SigninForm()
if request.method=='POST': #do the login
if form.validate()==False:
return render_template('login.html',form=form)
else:
session['email']=form.email.data
return redirect('/s1')
else: #show login form
return render_template('login.html',form=form)
示例6: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form=form)
else:
session['screenname'] = form.screenname.data
user = db.Users.find({'screenname':session['screenname']})
return redirect(url_for('profile'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例7: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form = form)
else:
user = db.session.query(User).filter(User.email == form.email.data).first()
session['uid'] = user.user_id
return redirect(url_for('user_timeline', uid=session['uid']))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例8: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form=form)
else:
session['email'] = form.email.data
flash('You are logged in')
print (str(session['email']),'is logged in')
return redirect(url_for('home'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例9: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if 'username' in session:
return redirect(url_for('dashboard'))
if request.method == 'POST':
if form.validate() == False:
return render_template('signin.html', form=form)
else:
session['username'] = form.username.data
return redirect(url_for('dashboard'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例10: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if request.method == 'POST':
if not form.validate():
return render_template('signin.html', form=form)
else:
session['email'] = form.email.data
user = User.query.filter_by(email=session['email']).first()
login_user(user)
flash('Logged in successfully!')
session['votes'] = []
return redirect(url_for('profile'))
elif request.method == 'GET':
return render_template('signin.html', form=form)
示例11: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
if 'email' in session:
return redirect(url_for('contacts'))
form = SigninForm()
if request.method == 'POST':
if form.validate(db) == False:
return render_template('home.html', form=form)
else:
session['email'] = form.email.data
return redirect(url_for('contacts'))
elif request.method == 'GET':
return render_template('home.html', form=form)
示例12: login
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def login():
form = SigninForm(db=db)
if 'email' in session:
return redirect(url_for('perfil'))
if request.method == 'POST':
if form.validate(db) == False:
return render_template('signin.html', form=form)
else:
session['email'] = form.email.data
user = db.session.query(User).filter_by(email = session['email']).first()
session['uid']=user.uid #guardo el id en la sesion para luego usarlo en las relaciones BD
return redirect(request.args.get("next") or url_for("perfil"))
else:
return render_template('signin.html', form=form)
示例13: multi_form
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def multi_form():
signin_form = SigninForm()
register_form = RegisterForm()
if signin_form.submit1.data and signin_form.validate():
username = signin_form.username.data
flash('%s, you just submit the Signin Form.' % username)
return redirect(url_for('index'))
if register_form.submit2.data and register_form.validate():
username = register_form.username.data
flash('%s, you just submit the Register Form.' % username)
return redirect(url_for('index'))
return render_template('2form.html', signin_form=signin_form, register_form=register_form)
示例14: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if 'email' in session:
return redirect(url_for('profile'))
if request.method == "POST":
if form.validate() == False:
return render_template("signin.html", form=form)
else:
session['email'] = form.email.data
return redirect(url_for('profile'))
elif request.method == "GET":
return render_template("signin.html", form=form)
示例15: signin
# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate [as 别名]
def signin():
form = SigninForm()
if 'username' in session:
return redirect(url_for('home'))
if request.method == 'POST':
if not form.validate():
return render_template('signin.html', form=form)
else:
session['username'] = form.username.data
flash('Login Successful.')
return redirect(url_for('home'))
elif request.method == 'GET':
return render_template('signin.html', form=form)