Skip to content

Latest commit

 

History

History
256 lines (184 loc) · 5.97 KB

README.pod

File metadata and controls

256 lines (184 loc) · 5.97 KB

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';

    # connecting with DBIx::Class

    sub find_user {
        my( $self, $name ) = @_;
        my $user = $schema->resultset( 'User' )->search({ username =>  $name })->next;
        return $user, $user->email, $user->pass_token if $user;
        return;
    }

    sub update_user {
        my( $self, $user, %attrs ) = @_;
        $user->update( \%attrs ); 
    }

}

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.

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)