当前位置: 首页>>代码示例>>Python>>正文


Python SigninForm.validate方法代码示例

本文整理汇总了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)
开发者ID:martinsoender,项目名称:PIS,代码行数:29,代码来源:routes.py

示例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)
开发者ID:Transformt,项目名称:peppe,代码行数:33,代码来源:routes.py

示例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)
开发者ID:DimaWittmann,项目名称:library,代码行数:10,代码来源:library.py

示例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)
开发者ID:bharatreddy,项目名称:thelogs,代码行数:12,代码来源:routes.py

示例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)
开发者ID:vishwashrisairam,项目名称:docsearchEngine,代码行数:13,代码来源:app.py

示例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)
开发者ID:Barneyjm,项目名称:School-Work,代码行数:15,代码来源:routes.py

示例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)
开发者ID:magicaljyy,项目名称:flask,代码行数:15,代码来源:routes.py

示例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)      
开发者ID:seanjohnson20,项目名称:BudgetBuddy,代码行数:16,代码来源:routes.py

示例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)
开发者ID:jasondecastro,项目名称:roadbeam,代码行数:17,代码来源:routes.py

示例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)
开发者ID:doubledare704,项目名称:testapp,代码行数:17,代码来源:views.py

示例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)
开发者ID:Dragost,项目名称:WebFlask,代码行数:17,代码来源:app.py

示例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) 
开发者ID:Dragost,项目名称:appCompletaFlask,代码行数:17,代码来源:app.py

示例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)
开发者ID:zx996,项目名称:helloflask,代码行数:17,代码来源:app.py

示例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)
开发者ID:kholidfu,项目名称:flask_login_mail,代码行数:17,代码来源:views.py

示例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)
开发者ID:jasonrahm,项目名称:rrftc,代码行数:18,代码来源:routes.py


注:本文中的forms.SigninForm.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。