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


Python form.LoginForm类代码示例

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


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

示例1: login

def login():
    errors = []
    form = LoginForm()
    if request.method == 'POST':
        if form.validate_on_submit() == False:
            flash('All fields are required')
            return render_template('login.html', form = form)
        else:
            email = request.form['email']
            password = request.form['password']
            print email , password
            db = connect_db()
            try:
                user_info = auth.authenticate_using_password(email, password, db)
                print user_info
            except BadPasswordError:
                flash("InValid Password")
                response = make_response(redirect(url_for('login')))
                return response
            except NoUserExistsError:
                flash("No User Exists")
                response = make_response(redirect(url_for('login')))
                return response
            session['access_token']= user_info['access_token']
            print "this is sesssion info: %s" %(dir(session))
            response = make_response(redirect(url_for('users')))
            return no_cache(response)


    else:
        return render_template('login.html', form = form)
开发者ID:kaushikdivya,项目名称:list_app,代码行数:31,代码来源:routes.py

示例2: login

def login():
    form = LoginForm()
    error = None

    if request.method == 'GET' and request.args.get('next'):
        session['next'] = request.args.get('next', None)

    if form.validate_on_submit():
        user = User.query.filter_by(
            username=form.username.data
        ).first()
        if user:
            if bcrypt.hashpw(form.password.data.encode('utf8'), salt) == user.password:
                session['username'] = user.username
                if 'next' in session:
                    next = session.get('next')
                    session.pop('next')
                    return redirect(next)
                else:
                    return redirect(url_for('index'))
            else:
                error = "Incorrect password"
        else:
            error = "User not found"
    return render_template('user/login.html', form=form, error=error)
开发者ID:joshua7v,项目名称:SeraphNav,代码行数:25,代码来源:views.py

示例3: home

def home():
	"""HOMEPAGE"""
	# if user hasn't logged out redirect won't reload login page
	if current_user is not None and current_user.is_authenticated():
		return render_template("main.html")

	message = ""
	message3 = ""
	form = LoginForm()
	
	# following occurs if form conditions are met
	if form.validate_on_submit():
		# query for the user in the database by email. If the user exists then the hashed password
		# is verified. If this password matches the email the user is logged in
		user = model.session.query(model.User).filter_by(email = form.email.data).first()
		if user:
			# salt_unicode = user.salt
			# salt = salt_unicode.encode('utf-8')
			password_unicode = form.password.data
			password = password_unicode.encode('utf-8')
			# hashed = bcrypt.hashpw(password, salt)
			
			if password == user.password_hash:
			# if hashed == user.password_hash:
				login_user(user)
			else:
				message3 = "Incorrect password"
				return render_template("main.html", form=form, message3=message3)

			message = "welcome back %s" % current_user.nickname
			return render_template("main.html", message=message)
		message3 = "It appears we don't have that account on file"
	return render_template("main.html", form=form, message3=message3)
开发者ID:12and1studio,项目名称:SketchApp,代码行数:33,代码来源:hipster.py

示例4: login

def login():
    error = None

    form = LoginForm(request.form)

    if request.method == 'POST':
        # if valid_login(
        #         request.form['username'], 
        #         request.form['password']):
        #     return "Welcome Back,  %s" % request.form.get('username')
        # else:
        #     error = "Incorrent username and password"
        if  form.validate_on_submit():
            user = User.query.filter_by(username=form.username.data).first()
            if user:
                if bcrypt.check_password_hash(user.password, form.password.data):
                    session['username'] = form.username.data
                    session['is_author'] = user.is_author
                    return redirect('/login_success')
            error ='Incorrect password'

            # user = User.query.filter_by(
            #  username=form.username.data,
            #  password=form.password.data).limit(1)
            
    return render_template("user/login.html", error=error, form=form)
开发者ID:sznote,项目名称:flask,代码行数:26,代码来源:app.py

示例5: login

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,代码行数:7,代码来源:gossip.py

示例6: login

def login():
    form = LoginForm()
    if form.validate_on_submit():
        login_user(form.admin)
        flash("Logged in successfully.")
        return redirect(request.args.get("next") or url_for("index"))
    return render_template("login.html", form=form)
开发者ID:zedzew,项目名称:flaskblog,代码行数:7,代码来源:views.py

示例7: login

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,代码行数:7,代码来源:tea.py

示例8: usLogin

def usLogin(request):
    context = {}
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            us = form.cleaned_data['us']
            pwd = form.cleaned_data['pwd']
            if r.exists('us:%s:id' %us):        # 检查是否存在该用户关系键值
                uid = r.get('us:%s:id' %us)     # 获取该用户在user表中对应的id
                if r.exists('user:%s' %uid):    # 检查是否存在该用户键值(如user:1)
                    us_, pwd_ = r.hmget('user:%s' %uid, 'username', 'pwd')  # 获取该用户的用户名密码
                    if us_ == us and pwd_ == pwd:   # 校验成功
                        r.hincrby('user:%s' %uid, 'login_count', 1)     # 登陆次数累加
                        r.hset('user:%s' %uid, 'last_login_date', datetime.datetime.now())  # 添加最近登陆
                        # set Cookies
                        res = HttpResponseRedirect('/')
                        ussys = usSystem(request, res, uid)
                        if ussys.testCookie() and ussys.setCookieAndSession():
                            return res

        context['msg'] = u'账号或密码错误'
        context['form'] = form

    request.session.set_test_cookie()
    form = LoginForm()
    context['form'] = form
    return render(request, 'login.html', context)
开发者ID:freedream520,项目名称:RedisPoem,代码行数:27,代码来源:views.py

示例9: login

def login():
	form = LoginForm()
	if form.validate_on_submit():
		flash('Login requested for OpenID="%s", remember_me=%s'% 
			(form.openid.data, str(form.remember_me.data)))
		return redirect('/index')
	return render_template('login.html', title = 'Sign In', form = form)
开发者ID:Lrraymond13,项目名称:Miniblog,代码行数:7,代码来源:server.py

示例10: login

 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,代码行数:8,代码来源:view.py

示例11: login

def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user, form.remember_me.data)
            return redirect(url_for('main.index'))
        flash("Invalid username or password")
    return render_template('auth/login.html', form=form)
开发者ID:zhkmxx9302013,项目名称:ComBlog,代码行数:9,代码来源:views.py

示例12: login

def login():
    form = LoginForm()
    if form.validate_on_submit():
        flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data))
        return redirect('/index')
    return render_template('login.html',
                           title = 'Sign In',
                           form = form,
                           providers = app.config['OPENID_PROVIDERS'])
开发者ID:lalalacampanella,项目名称:microblogHub,代码行数:9,代码来源:views.py

示例13: user_register

def user_register():
    name=None
    form = LoginForm(request.form)
    if request.method=='POST':
        if form.validate_on_submit():
            session['name'] = request.form['username']
            session['logged_in'] = True
            return redirect(url_for('newgame'))
    return render_template('login.html', form=form)
开发者ID:isams1,项目名称:guessgame,代码行数:9,代码来源:guessgame.py

示例14: user_login

def user_login():
    form = LoginForm()
    if form.validate_on_submit():
        user = users.get_user(form.name.data)
        login_user(user)
        user.set('authenticated', True)
        flash('Login successful.', 'success')
        return redirect(request.args.get("next") or url_for('index'))
    return render_template('login.html', form=form)
开发者ID:Elenw,项目名称:zwiki,代码行数:9,代码来源:app.py

示例15: login

def login():    
    form = LoginForm(csrf_enabled=False) 
              
    if form.validate_on_submit():
        user = User.query.filter_by(username = form.username.data).first()
        if user is not None and User.query.filter_by(password = form.password.data).first():
            login_user(user)
            return redirect(url_for('admin'))                
        else:
            return redirect(url_for('login')) 
    return render_template('login.html', form = form)
开发者ID:Nana2mini,项目名称:Flask-Blog,代码行数:11,代码来源:views.py


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