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


Python SigninForm.validate_on_submit方法代码示例

本文整理汇总了Python中forms.SigninForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python SigninForm.validate_on_submit方法的具体用法?Python SigninForm.validate_on_submit怎么用?Python SigninForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.SigninForm的用法示例。


在下文中一共展示了SigninForm.validate_on_submit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: signin

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
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)
开发者ID:GriffinHeart,项目名称:Dodgeball,代码行数:37,代码来源:viewsLogin.py

示例2: signin

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
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)
开发者ID:mitchheard,项目名称:mitchheardcom,代码行数:10,代码来源:views.py

示例3: post

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
 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)
开发者ID:ratazzi,项目名称:dashboard,代码行数:10,代码来源:handlers.py

示例4: login

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
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, )
开发者ID:PESTLab,项目名称:team-b,代码行数:10,代码来源:views.py

示例5: login

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
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)
开发者ID:yucenli,项目名称:tartanhacks2016,代码行数:14,代码来源:views.py

示例6: signin

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
def signin():
  login = SigninForm() 
  if ('project' in session) or ('judge' in session):
    return redirect(url_for('profile')) 
  if login.validate_on_submit(): # means that user is either judge or project member 
    if login.findmember():
      session['project'] = login.getproject() # sets to id of project 
    elif login.findjudge():
      session['judge'] = login.findjudge() # sets to id of judge
    elif login.findadmin():
      session['admin'] = login.findadmin()
    return redirect(url_for('profile'))
  flash('Incorrect login details. Please try again or register for a new account.')
  return redirect(url_for('login')) 
开发者ID:Pennvention,项目名称:pvapp,代码行数:16,代码来源:routes.py

示例7: login

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
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)
开发者ID:cedricbonhomme,项目名称:Grenouille,代码行数:17,代码来源:views.py

示例8: signin

# 需要导入模块: from forms import SigninForm [as 别名]
# 或者: from forms.SigninForm import validate_on_submit [as 别名]
def signin():
    """
    signin form
    """

    error = None
    form = SigninForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()

        if user and check_password_hash(user.password, form.password.data):
            session["username"] = user.username
            return redirect(url_for("index"))
        else:
            error = "wrong combination username/password"
            flash(error)

    return render_template("forms/signin.html", title="Sign in", form=form, error=error)
开发者ID:albertogg,项目名称:Torrentbox,代码行数:20,代码来源:flaskmon.py


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