Пример #1
0
    def _reset_password(self, user, password):
        user.password = password

        self.request.session.flash(jinja2.Markup(_(
            'Your password has been reset! '
            'You can now <a href="{url}">login</a> using the new password you '
            'provided.').format(url=self.request.route_url('login'))),
            'success')
        self.request.registry.notify(PasswordResetEvent(self.request, user))
Пример #2
0
    def _reset_password(self, user, password):
        svc = self.request.find_service(name='user_password')
        svc.update_password(user, password)

        self.request.session.flash(jinja2.Markup(_(
            'Your password has been reset. '
            'You can now <a href="{url}">login</a> with your new '
            'password.').format(url=self.request.route_url('login'))),
            'success')
        self.request.registry.notify(PasswordResetEvent(self.request, user))
Пример #3
0
    def _reset_password(self, user, password):
        svc = self.request.find_service(name="user_password")
        svc.update_password(user, password)

        self.request.session.flash(
            jinja2.Markup(
                _("Your password has been reset. You can now log in with "
                  "your new password.")),
            "success",
        )
        self.request.registry.notify(PasswordResetEvent(self.request, user))
Пример #4
0
    def _reset_password(self, user, password):
        svc = self.request.find_service(name="user_password")
        svc.update_password(user, password)

        self.request.session.flash(
            jinja2.Markup(
                _("Your password has been reset. "
                  'You can now <a href="{url}">login</a> with your new '
                  "password.").format(url=self.request.route_url("login"))),
            "success",
        )
        self.request.registry.notify(PasswordResetEvent(self.request, user))
Пример #5
0
    def reset_password(self):
        """
        Handle submission of the reset password form.

        This function checks that the activation code (i.e. reset token)
        provided by the form is valid, retrieves the user associated with the
        activation code, and resets their password.
        """
        schema = schemas.ResetPasswordSchema().bind(request=self.request)
        form = deform.Form(schema)

        code = self.request.matchdict.get('code')
        if code is None:
            return httpexceptions.HTTPNotFound()

        activation = Activation.get_by_code(code)
        if activation is None:
            return httpexceptions.HTTPNotFound()

        user = User.get_by_activation(activation)
        if user is None:
            return httpexceptions.HTTPNotFound()

        if self.request.method != 'POST':
            return httpexceptions.HTTPMethodNotAllowed()

        err, appstruct = validate_form(form, self.request.POST.items())
        if err is not None:
            return err

        user.password = appstruct['password']
        self.request.db.delete(activation)

        self.request.session.flash(_('Your password has been reset!'),
                                   'success')
        self.request.registry.notify(PasswordResetEvent(self.request, user))

        return httpexceptions.HTTPFound(location=self.reset_password_redirect)