def POST(self):
     f = form.login_form()
     if not f.validates():
         return render({'title': settings.SITE_NAME}).login(session.user, f)
     else:
         session.user = f['username'].value
         return web.redirect("/")
 def POST(self):
     f = form.login_form()
     if not f.validates():
         return render({'title': settings.SITE_NAME}).login(session.user, f)
     else:
         session.user = f['username'].value
         return web.redirect("/")
示例#3
0
 def POST(self):
     if web.ctx.session.login==False:
         f=form.login_form()
         if not f.validates():
             msg=ERR_LOGIN_INFO
             return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).login(f,msg)
         else:
             info=web.input()
             msg,pri=models.check_login(info.username,info.password)
             if msg!='':
                 return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).login(f,msg)
             else:
                 web.ctx.session.login=True
                 web.ctx.session.username=info.username
                 web.ctx.session.privilege=pri
                 raise web.seeother("/../")
     else:
         raise web.seeother("/../")
示例#4
0
文件: app.py 项目: ektaarora3501/amoc
def login():
    form = login_form()
    if form.validate_on_submit():
        mail = request.form.get("email")
        pw = request.form.get("password")
        #pwd=bcrypt.generate_password_hash(pw).decode('utf-8')
        user = request.form.get("username")
        i = 1
        u2 = data_user.query.filter_by(id=i).first()
        while (1):
            u2 = data_user.query.filter_by(id=i).first()
            if (u2 is None):
                break
            else:
                if (u2.email == mail):
                    if (u2.password == pw):
                        return redirect(url_for('logged', username=user))

            i = i + 1
    return render_template('login.html', form=form)
示例#5
0
def sessions(username):
    form = login_form()

    u2 = log2.query.filter_by(user_name=username).first()
    print(u2)
    if (u2 is None):
        return redirect(url_for('login'))

    elif (username == 'zuerst'):
        return render_template('admin.html',
                               username=username,
                               user_code=user_code,
                               log2=log2)
        return render_template('report.html',
                               username=username,
                               user_code=user_code)
    else:
        return render_template('session.html', username=username, log2=log2)
        return render_template('report.html',
                               username=username,
                               user_code=user_code)
示例#6
0
def login():
    form = login_form()
    if form.validate_on_submit():
        mail = request.form.get("email")
        pw = request.form.get("password")
        user = request.form.get("username")

        u2 = database.query.filter_by(user_name=user).first()
        print(database.query.all())
        if (u2 is None):
            print(u2)
            return render_template('login.html', form=form)

        elif (u2.user_name == 'zuerst'):
            if (u2.password == 'zuerst123'):
                u = log2(user_name=u2.user_name)
                db.session.add(u)
                db.session.commit()
                print(log2.query.all())
                return redirect(url_for('sessions', username=user))

        elif (u2.email == mail):
            if (u2.password == pw):
                u = log2(user_name=u2.user_name)
                try:
                    db.session.add(u)
                    db.session.commit()
                    print(log2.query.all())
                    return redirect(url_for('sessions', username=user))

                except (InvalidRequestError, IntegrityError):
                    return redirect(url_for('sessions', username=user))

        error = 'invalid login'
        return render_template('login.html', form=form, error=error)
    return render_template('login.html', form=form)
示例#7
0
def login():
    form=login_form()
    if form.validate_on_submit():
        name=request.form.get('username')
        pas=request.form.get('password')
        user=regis.query.filter_by(user_name=name).first()
        if(user==None):
            error="invalid login"
            return render_template("login.html",form=form,error=error)
        else:
            if(pas==user.password):
                 m=logged(user_name=name)
                 db.session.add(m)
                 try:
                     db.session.commit()
                     print(logged.query.all())
                     return redirect(url_for('dashboard',username=name))
                 except(IntegrityError):
                     return redirect(url_for('dashboard',username=name))
            else:
                error ='Invalid login !!!!'
                return render_template("login.html",form=form,error=error)

    return render_template("login.html",form=form)
 def GET(self):
     f = form.login_form()
     return render({'title': settings.SITE_NAME}).login(session.user, f)
示例#9
0
def login():
    form = login_form()
    if form.validate_on_submit():
        print("valid")
    return render_template("login.html", form=form)
示例#10
0
 def GET(self):
     if web.ctx.session.login==True:
         raise web.seeother("/../")
     else:
         f=form.login_form()
         return web.template.render('templates/',base='base',globals={'session':web.ctx.session}).login(f)
 def GET(self):
     f = form.login_form()
     return render({'title': settings.SITE_NAME}).login(session.user, f)