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


Python forms.SigninForm类代码示例

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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