Esempio n. 1
0
    def reset(self):
        request = self.request
        registry = request.registry
        data, errors = self.extract()

        login = data.get('login')
        if login:
            principal = authService.get_principal_bylogin(login)

            if principal is not None and \
                   passwordTool.can_change_password(principal):

                passcode = passwordTool.generate_passcode(principal)

                template = ResetPasswordTemplate(principal, request)
                template.passcode = passcode
                template.send()

                self.request.registry.notify(
                    ResetPasswordInitiatedEvent(principal))

                self.message(_('Password reseting process has been initiated. '
                               'Check your email for futher instructions.'))
                raise HTTPFound(location=request.application_url)

        self.message(_(u"System can't restore password for this user."))
Esempio n. 2
0
    def update(self):
        request = self.request
        passcode = request.params.get("passcode")
        self.principal = principal = passwordTool.get_principal(passcode)

        if principal is not None and passwordTool.can_change_password(principal.uri):
            self.passcode = passcode
            self.title = principal.name or principal.login
        else:
            self.message(_("Passcode is invalid."), "warning")
            raise HTTPFound(location="%s/resetpassword.html" % request.application_url)

        super(ResetPasswordForm, self).update()
Esempio n. 3
0
    def update(self):
        request = self.request

        passcode = request.subpath[0]
        self.principal = principal = passwordTool.get_principal(passcode)

        if principal is not None and \
               passwordTool.can_change_password(principal):
            self.passcode = passcode
            self.title = principal.name or principal.login
        else:
            self.message(_("Passcode is invalid."), 'warning')
            raise HTTPFound(
                location='%s/resetpassword.html'%request.application_url)

        super(ResetPasswordForm, self).update()
Esempio n. 4
0
    def reset(self):
        request = self.request
        registry = request.registry
        data, errors = self.extract()

        login = data.get("login")
        if login:
            principal = authService.get_principal_bylogin(login)

            if principal is not None and passwordTool.can_change_password(principal):

                passcode = passwordTool.generate_passcode(principal)

                template = ResetPasswordTemplate(principal, request)
                template.passcode = passcode
                template.send()

                self.request.registry.notify(ResetPasswordInitiatedEvent(principal))

                self.message(_("Your password has been " "reset and is being emailed to you."))
                raise HTTPFound(location=request.application_url)

        self.message(_(u"System can't restore password for this user."))