Example #1
0
File: view.py Project: F9O/govsite
    def POST(self):
        form = admin_login_form()
        req = web.ctx.req
        if not form.validates():
            req.update({
                'form': form,
                })
            return render.login(**req)
        data = web.input()
        errcode, user = admin_authenticate(data.username, data.password)
        if errcode != ERR_OK:
            if errcode == ERR_USER_NOTEXISTS:
                form.note = u'用户未注册'
            elif errcode == ERR_NOTACTIVE:
                form.note = u'用户未激活'
            elif errcode == ERR_PASSWORD_NOTCORRECT:
                form.note = u'密码错误'
            elif errcode == ERR_NOTSUPERUSER:
                form.note = u'不是管理员用户'

            req.update({
                'form': form,
                })
            return render.login(**req)

        auth_login(user)
        raise web.seeother('/')
Example #2
0
File: view.py Project: F9O/govsite
 def GET(self):
     if is_admin_logined():
         raise web.seeother('/')
     data = web.input()
     form = admin_login_form()
     req = web.ctx.req
     req.update({
         'form': form,
         })
     return render.login(**req)