Esempio n. 1
0
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'),
    }
Esempio n. 2
0
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"),
    }
Esempio n. 3
0
def get_auth(app, to='/'):
    return Auth.from_app(app, to)
Esempio n. 4
0
 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')
Esempio n. 5
0
 def login_to_url(self, to):
     return self.request.link(Auth.from_request(self.request, to=to),
                              name='login')
Esempio n. 6
0
def get_auth(request, to='/'):
    return Auth.from_request(request, to)
Esempio n. 7
0
 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')
Esempio n. 8
0
 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'
     )