Esempio n. 1
0
        membership_tool = getToolByName(self.context, 'portal_membership')
        member = membership_tool.getMemberById(username)

        # XXX: Improve this for further fields
        member.setMemberProperties({'email': email})

        login_time = member.getProperty('login_time', '2000/01/01')
        if not isinstance(login_time, DateTime):
            login_time = DateTime(login_time)
        initial_login = login_time == DateTime('2000/01/01')
        if initial_login:
            # TODO: Redirect if this is initial login
            pass

        IStatusMessage(self.request).addStatusMessage(
            _(u'statusmessage_your_now_logged_in',
              default=u'You are now '
              u'logged in.'), 'info')

        # TODO: Add way to configure the redirect
        self.request.response.redirect(self.context.absolute_url())


class RegisterFormView(layout.FormWrapper):
    form = RegisterForm


wrapped_register_template = FormTemplateFactory(template_path('register.pt'),
                                                form=IRegisterForm,
                                                request=IPloneLoginLayer)
Esempio n. 2
0
                                    IRedirectAfterLogin)
        if adapter:
            came_from = adapter(came_from)
        else:
            if not came_from:
                came_from = self.context.portal_url()

        self.request.response.redirect(came_from)


class LoginFormView(layout.FormWrapper):
    form = LoginForm


wrapped_login_template = FormTemplateFactory(
    template_path('login.pt'),
    form=ILoginForm,
    request=IPloneLoginLayer
)


class RequireLoginView(BrowserView):

    def __call__(self):
        portal_state = getMultiAdapter((self.context, self.request),
                                       name='plone_portal_state')
        portal = portal_state.portal()
        if portal_state.anonymous():
            url = '{0:s}/login'.format(portal.absolute_url())
            came_from = self.request.get('came_from', None)
            if came_from:
Esempio n. 3
0
        # Try traverse subpath first:
        try:
            key = self.request['TraversalRequestNameStack'][:0]
        except IndexError:
            key = None

        # Fall back to request variable for BW compat
        if not key:
            key = self.request.get('key', None)

        pw_tool = getToolByName(self.context, 'portal_password_reset')
        # key is the value for arg randomstring
        pw_tool.resetPassword(current, key, data.get('password'))

        IStatusMessage(self.request).addStatusMessage(
            _(u'statusmessage_pwreset_passwort_was_reset', default=u'Your '
              u'password has been reset.'), 'info')

        self.request.response.redirect(self.context.absolute_url())


class ResetPasswordFormView(layout.FormWrapper):
    form = ResetPasswordForm


wrapped_pwreset_template = FormTemplateFactory(
    template_path('reset_password.pt'),
    form=IResetPasswordForm,
    request=IPloneLoginLayer
)