コード例 #1
0
ファイル: view.py プロジェクト: FashtimeDotCom/pycmsdemo
    def POST(self):
        form = admin_login_form()
        req = web.ctx.req
        if not form.validates():
            req.update({
                'form': form,
                })
            return admin_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 admin_render.login(**req)

        auth_login(user)
        raise web.seeother('/')
コード例 #2
0
ファイル: view.py プロジェクト: FashtimeDotCom/pycms
    def POST(self):
        form = login_form()
        if not form.validates():
            return render.login(form=form)
        data = web.input()
        errcode, user = authenticate(data.username, data.password)
        req = web.ctx.req
        if errcode != ERR_OK:
            if errcode == ERR_USER_NOTEXISTS:
                req.err(u'用户未注册')
            elif errcode == ERR_PASSWORD_NOTCORRECT:
                req.err(u'密码错误')

            if 'redirect_to' in data:
                redirect_url = data.redirect_to
            req.update({
                'form': form,
                'redirect_url': redirect_url,
                })
            return render.login(**req)
        auth_login(user)
        redirect_url = data.redirect_to
        if redirect_url:
            raise web.seeother(redirect_url)
        else:
            raise web.seeother('/', True)
コード例 #3
0
ファイル: view.py プロジェクト: zhangjinde/pycms
    def POST(self):
        form = login_form()
        if not form.validates():
            return render.login(form=form)
        data = web.input()
        errcode, user = authenticate(data.username, data.password)
        req = web.ctx.req
        if errcode != ERR_OK:
            if errcode == ERR_USER_NOTEXISTS:
                req.err(u'用户未注册')
            elif errcode == ERR_PASSWORD_NOTCORRECT:
                req.err(u'密码错误')

            if 'redirect_to' in data:
                redirect_url = data.redirect_to
            req.update({
                'form': form,
                'redirect_url': redirect_url,
            })
            return render.login(**req)
        auth_login(user)
        redirect_url = data.redirect_to
        if redirect_url:
            raise web.seeother(redirect_url)
        else:
            raise web.seeother('/', True)