本文整理汇总了Python中forms.SigninForm类的典型用法代码示例。如果您正苦于以下问题:Python SigninForm类的具体用法?Python SigninForm怎么用?Python SigninForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SigninForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signin
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)
示例2: signin
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)
示例3: signin
def signin():
form = SigninForm()
if form.validate_on_submit():
if len(User.query.filter_by(nickname=form.nickname.data).all()) > 0:
flash(gettext("Selected username already exists!"), category='alert-danger')
return redirect(url_for('signin'))
new_email = form.email.data
check_mail = User.query.filter_by(email=new_email).all()
#user mail already exists
if len(check_mail) > 0:
flash(gettext('Selected email is already in use!'), category='alert-danger')
return redirect(url_for('signin'))
user = User()
user.nickname = form.nickname.data
user.password = generate_password_hash(form.password.data)
user.email = new_email
user.language = form.language.data
# default role is user, not admin
user.role = USER_ROLES['ROLE_USER']
db.session.add(user)
db.session.commit()
flash(gettext('Thank you for joining us!'))
return redirect(url_for('index'))
return render_template('login/signin.html',
title=gettext('Sign In'),
form=form)
示例4: post
def post(self):
next_url = request.args.get('next', '/')
form = SigninForm()
if form.validate_on_submit():
session.permanent = True
session['username'] = form.username.data
return redirect(next_url)
return render_template('signin.html', form=form)
示例5: login
def login():
if g.user is not None and g.user.is_authenticated():
return redirect(url_for('index'))
form = SigninForm()
if form.validate_on_submit():
session['remember_me'] = form.remember_me.data
return oid.try_login(app.config['GOOGLE_OPENID'], ask_for=['nickname', 'email'])
return render_template('signin.html', title='Sign In', form=form, )
示例6: sign_in
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)
示例7: signin
def signin():
form = SigninForm()
if form.validate_on_submit():
session['email'] = form.email.data
person = Person.query.filter_by(email=session['email']).first()
name = person.firstname
return redirect(url_for('dashboard', name=name))
return render_template('signin.html', form=form)
示例8: signin
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)
示例9: login
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)
示例10: login
def login():
form = SigninForm()
if form.validate_on_submit():
user = User.query.get(form.andrewid.data)
if user:
if bcrypt.check_password_hash(user.password, form.password.data):
user.authenticated = True
db.session.add(user)
db.session.commit()
login_user(user, remember=True)
return render_template('profile.html', user=user)
return render_template('signin.html', form=form)
示例11: signin
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)
示例12: signin
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)
示例13: signin
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)
示例14: signin
def signin(request):
if request.method == "POST":
form = SigninForm(request.POST)
if form.is_valid():
form.save()
newUser=authenticate(username=form.cleaned_data["username"],
password=form.cleaned_data["password1"])
authlogin(request, newUser)
return HttpResponseRedirect("/")
else :
form = SigninForm()
data={
"form":form,
}
return render(request,"blog/mobile/registration/signin.html",data)
示例15: login
def login():
"""
Log in view.
"""
g.user = AnonymousUserMixin()
form = SigninForm()
if form.validate_on_submit():
user = User.query.filter(User.email == form.email.data).first()
login_user(user)
g.user = user
identity_changed.send(current_app._get_current_object(), identity=Identity(user.id))
flash("Logged in successfully.", 'success')
return redirect(url_for('profile'))
return render_template('login.html', form=form)