def handle_login(self, request, form): """ Handles the login requests. """ form.delete_field('yubikey') if form.submitted(request): response = self.login_to(request=request, **form.login_data) form.error_message = _("Wrong username or password") else: response = None return response or { 'layout': DefaultLayout(self, request), 'title': _("Login"), 'form': form, 'password_reset_link': request.link(Auth.from_request(request), name='request-password'), }
def handle_login(self, request, form): """ Handles the login requests. """ layout = DefaultLayout(self, request) if form.submitted(request): self.to = relative_url(layout.homepage_url) response = self.login_to(request=request, **form.login_data) form.error_message = _("Wrong username or password") else: response = None return response or { 'layout': layout, 'title': _("Login"), 'form': form, 'password_reset_link': request.link(Auth.from_request(request), name='request-password'), 'button_text': _("Submit"), }
def get_auth(app, to='/'): return Auth.from_app(app, to)
def logout_url(self): if self.request.is_logged_in: return self.request.link(Auth.from_request(self.request, to=self.homepage_url), name='logout')
def login_to_url(self, to): return self.request.link(Auth.from_request(self.request, to=to), name='login')
def get_auth(request, to='/'): return Auth.from_request(request, to)
def login_link(self): if not self.request.is_logged_in: return self.request.link(Auth.from_request(self.request, to=self.homepage_link), name='login')
def logout_url(self): """ Returns the logout url for the current page. """ return self.request.link( Auth.from_app(self.app, self.request.transform(self.request.path)), name='logout' )