Пример #1
0
 def test_login1(self):
     form = LoginForm(password="******")
     #form1 = SignupForm(username= u"tester1", password= u"testing",password_again=u"testing",email=u"*****@*****.**", submit = "True")
     #form2 = EditAccountForm(username=u"tester", email = u"*****@*****.**", submit = "True")
     #form3 = ChangePasswordForm(password = u"test1ing", password_again = u"test1ing", submit= "True")
     form.validate()
     assert form.errors.get("login") == ['Need an email or username']
Пример #2
0
def login():
    form = LoginForm(login=request.args.get("login", None),
                     next=request.args.get("next", None))

    if form.validate_on_submit():
        user, auth = \
            User.query.authenticate(form.login.data, form.password.data)
        if user and auth:
            session.permanent = form.remember

            identity_changed.send(current_app._get_current_object(),
                                  identity=Identity(user.id))
            #need add next url
            flash(u"welcome {0}".format(user.username), "success")
            return redirect(url_for('index.index'))
        else:
            flash(u"无效登陆,请检查用户名或者密码", "error")

    return render_template('account/login.html', form=form)
Пример #3
0
def login():
    form = LoginForm(login=request.args.get("login", None),
                     next=request.args.get("next", None))

    if form.validate_on_submit():
        user, auth = \
            User.query.authenticate(form.login.data, form.password.data)
        if user and auth:
            session.permanent = form.remember

            identity_changed.send(current_app._get_current_object(),
                                  identity=Identity(user.id))
            # need add next url
            flash(u"welcome {0}".format(user.username), "success")
            return redirect(url_for('index.index'))
        else:
            flash(u"无效登陆,请检查用户名或者密码", "error")

    return render_template('account/login.html', form=form)
Пример #4
0
 def test_login6(self):
     form = LoginForm(login=u"tester", password=u"testing", submit=True)
     print dir(form)
     print form.validate()
     self.assertEqual(form.validate(), True)
Пример #5
0
 def test_login5(self):
     form = LoginForm(login="******", password="******")
     self.assertEqual(form.validate(), False)
Пример #6
0
 def test_login3(self):
     form = LoginForm(login="******")
     form.validate()
     assert form.errors.get("password") == ['Need a password']
Пример #7
0
 def test_login2(self):
     form = LoginForm()
     form.validate()
     assert form.errors.get("login") == ['Need an email or username']
     assert form.errors.get("password") == ['Need a password']