Exemple #1
0
    def login(self):
        try:
            json_body = self.request.json_body
        except ValueError as err:
            raise accounts.JSONError(
                _('Could not parse request body as JSON: {message}'.format(
                    message=err.message)))

        if not isinstance(json_body, dict):
            raise accounts.JSONError(
                _('Request JSON body must have a top-level object'))

        # Transform non-string usernames and password into strings.
        # Deform crashes otherwise.
        json_body['username'] = unicode(json_body.get('username') or '')
        json_body['password'] = unicode(json_body.get('password') or '')

        appstruct = self.form.validate(json_body.items())

        user = appstruct['user']
        headers = self._login(user)
        self.request.response.headers.extend(headers)

        return ajax_payload(self.request, {'status': 'okay'})
Exemple #2
0
def dismiss_sidebar_tutorial(request):
    if request.authenticated_userid is None:
        raise accounts.JSONError()
    else:
        request.user.sidebar_tutorial_dismissed = True
        return ajax_payload(request, {"status": "okay"})