예제 #1
0
def handle_password_reset(self, request, form):
    request.include("common")
    request.include("check_password")

    if form.submitted(request):
        identity = form.get_identity(request)
        if identity is not None:
            response = morepath.redirect(request.link(self))
            morepath.remember_identity(response, request, identity)
            request.success(_("Password changed."))
            return response
        else:
            request.alert(_("Wrong username or password reset link not valid any more."))
            log.info("Failed password reset attempt by {}".format(request.client_addr))

    if "token" in request.params:
        form.token.data = request.params["token"]

    layout = DefaultLayout(self, request)
    layout.breadcrumbs = [
        Link(_("Homepage"), layout.homepage_url),
        Link(_("Reset password"), request.link(self, name="request-password")),
    ]

    return {"layout": layout, "title": _(u"Reset password"), "form": form, "form_width": "small"}
예제 #2
0
    def remember(response):
        # This demonstrates that the function is indeed called
        print('trying to remember {} with {}'.format(username, password))

        identity = mp.Identity(username)
        mp.remember_identity(response, request, identity)
예제 #3
0
 def default(self, request):
     response = Response()
     morepath.remember_identity(response, request, Identity('foo'),
                                lookup=request.lookup)
     return response
예제 #4
0
 def remember(response):
     identity = Identity(username, fullname=fullname, email=email, role=role)
     morepath.remember_identity(response, request, identity,
                                lookup=request.lookup)
예제 #5
0
 def remember(response):
     identity = Identity(username)
     morepath.remember_identity(response, request, identity,
                                lookup=request.lookup)