def login(): if env.user.id: if env.request.is_xhr: raise AlreadyAuthorized return Response( redirect='%s://%s%s' % (env.request.protocol, settings.domain, userlink(env.user))) ref = referer() try: login = env.request.args('login') password = env.request.args('password') if not login or not password: raise NotAuthorized env.user.authenticate(login, password) if env.request.is_xhr: return Response(ok=True) else: return Response(redirect=ref) except (KeyError, NotAuthorized): return Response(template='/auth/login.html', code=NotAuthorized.code, message=NotAuthorized.message, errors={'password': '******'}, referer=ref, fields=ULOGIN_FIELDS)
def handleMatch(self, m): try: User('login', m.group('u')) except UserNotFound: return #'@'+m.group('u') a = etree.Element('a') a.set('href', userlink(m.group('u'))) a.set('class', 'user js-navigate') a.text = m.group('u') return a
def login(): if env.user.id: if env.request.is_xhr: raise AlreadyAuthorized return Response(redirect="%s://%s%s" % (env.request.protocol, settings.domain, userlink(env.user))) ref = referer() try: login = env.request.args("login") password = env.request.args("password") if not login or not password: raise NotAuthorized env.user.authenticate(login, password) if env.request.is_xhr: return Response(ok=True) else: return Response(redirect=ref) except (KeyError, NotAuthorized): return Response( template="/auth/login.html", code=NotAuthorized.code, message=NotAuthorized.message, errors={"password": "******"}, referer=ref, fields=ULOGIN_FIELDS, )
def userlink_filter(environ, user, path=''): return userlink(user, path)