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


Python LoginForm.validate方法代码示例

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


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

示例1: login

# 需要导入模块: from form import LoginForm [as 别名]
# 或者: from form.LoginForm import validate [as 别名]
def login():
    form = LoginForm(request.form)
    if request.method == "POST" and form.validate():
        if form.username.data == "bsspirit" and form.password.data == "85831923":
            session["login"] = True
            return redirect(url_for("admin"))
    return render_template("login.html")
开发者ID:bsspirit,项目名称:WhiteTea,代码行数:9,代码来源:tea.py

示例2: login

# 需要导入模块: from form import LoginForm [as 别名]
# 或者: from form.LoginForm import validate [as 别名]
def login():
    form = LoginForm(request.form)
    if request.method == 'POST' and form.validate():
        user_id = form.get_user().user_id
        session['user_id'] = user_id
        return redirect(url_for('user_index', user_id=user_id))
    return render_template('login.html', form=form)
开发者ID:alanlogic,项目名称:gossip,代码行数:9,代码来源:gossip.py

示例3: login

# 需要导入模块: from form import LoginForm [as 别名]
# 或者: from form.LoginForm import validate [as 别名]
 def login(self):
     form = LoginForm(request.form)
     if request.method == 'POST' and form.validate():
         user = form.get_user()
         login_user(user)
         redirect(url_for('.index'))
     self._template_args['form']=form
     return super(MyIndexView,self).index()
开发者ID:fanne,项目名称:FlaskMongodbBlog,代码行数:10,代码来源:view.py

示例4: login

# 需要导入模块: from form import LoginForm [as 别名]
# 或者: from form.LoginForm import validate [as 别名]
def login():
    form = LoginForm(request.form)
    result = '';

    if request.method == 'POST' and form.validate():
        u = User.query.filter_by(email=form.email.data).first()

        if u == None:
            flash('User not exists.', 'warning')
        else:
            user = User(u.email, '', u.nick_name)
            user.id = u.id
            user.password_hash = u.password_hash
            if user.verify_password(form.password.data):
                login_user(user, remember=form.remember.data)
                # flash('Hi~ %s, you just login success.' % user.getDisplayName(), 'warning')

                return redirect(url_for('main.index'))
            else:
                flash('password incorrect', 'error')

    return render_template('login.html', title='login', form=form);
开发者ID:keelii,项目名称:snote,代码行数:24,代码来源:views.py

示例5: login

# 需要导入模块: from form import LoginForm [as 别名]
# 或者: from form.LoginForm import validate [as 别名]
def login():
    """Render the website's login page."""
    try:
        form = LoginForm(csrf_enabled=False)
        if request.method == "POST":
            if form.validate()==False:
                flash('All fields are required.')
                return render_template('login.html',form=form)
            else:
                c, conn = connection()
                data = c.execute("SELECT * FROM user WHERE email = '"+thwart(form.Email.data)+"'")

                data = c.fetchone()[2]
                user_id = c.fetchone()[0]
            
                if bcrypt.check_password_hash(data,form.password.data):
                    session['logged_in'] = True
                    session['email'] = form.Email.data
                    session['user_id'] = str(user_id)

                    flash("You are now logged in")
                    return render_template("home.html")

                else:
                    error = "Invalid credentials, try again."
                    return render_template("login.html",  form=form ,error = error)

            gc.collect()

        elif request.method=='GET':
            return render_template('login.html', form=form)

    except Exception as e:
        #flash(e)
        error = "Invalid credentials, try again."
        return render_template("login.html",  form=form ,error = error)  
开发者ID:ShaneRich5,项目名称:comp3161,代码行数:38,代码来源:views.py


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