Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A plack component implementing the common reset forgotten password mechanism
Perl
tree: 73aa616749

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Plack/App
t
Changes
README.html
README.pod
dist.ini

README.pod

NAME

Plack::App::ResetPass - (Experimental) Plack application for sending a 'Reset password link' via email

VERSION

version 0.001

SYNOPSIS

    {
        package My::ResetPass;
        use parent 'Plack::App::ResetPass';

        sub find_user {
            my( $self, $name ) = @_;
            return 1, 'test@example.com', 'a' if $name eq 'right_name';
            return;
        }

        sub send_mail {
            my( $self, $email ) = @_;
            return $email;
        }

        sub update_user {}

    }

    my $app = My::ResetPass->new;

    my $mounted_app = builder {
        mount "/forgotten_pass" => builder {
            sub{ $app->call( shift ) };
        };
    };

DESCRIPTION

This application implements the common reset forgotten password mechanism. It has two pages. First page where the user enters his login details and if they are correct an email with a link (with a random verification token) to the password reset page is sent. Second page - the password reset page - checks the token - and lets the user to choose a new password.

This application uses the Template Method design pattern.

PURE VIRTUAL METHODS

These methods need to be overriden in subclass.

find_user ( name )

Should return a following tuple $user, $user_email, $verification_token

The $user is user object - passed to the update_user method

update_user ( user, %params )

Should update the user object with %params. It is used for saving the new password and verification token.

VIRTUAL METHODS

These methods have defaults - but should probably be overriden anyway.

wrap_text ( text )

Should return the html page containing the passed text fragment. By default it just adds the html and body tags.

build_mail ( to_address, link_to_the_reset_page )

Should create the email containing the link.

send_mail ( mail )

Should send the mail (created by build_mail).

OTHER METHODS

call ( env )

SEE ALSO

Plack Plack::Middleware::Auth::Form

AUTHOR

Zbigniew Lukasiak <zby@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2011 by Zbigniew Lukasiak <zby@cpan.org>.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
Something went wrong with that request. Please try again.