Example #1
0
def login():
    '''
    @todo:登录
    '''
    user =  vertify_user(
        request.form.get('_id', ''),
        request.form.get('password', '')
    )
    if user:
        session.update(set_user_session({}, user))
        session.permanent = True
        return redirect(request.headers.get("Referer", "/"))
    else:
        session['err_msg'] = u"帐号密码错误"
        if request.form.get("return", None):
            return render_template('login.html',login="******",  info=u"帐号密码错误")
        else:
            return redirect(request.headers.get("Referer", "/"))
Example #2
0
 def test_vertify_user(self):
     self.assertEqual(vertify_user('', '' ), False)
     self.assertTrue(bool(vertify_user('test', 'test')))