Plack::App::ResetPass - (Experimental) Plack application for sending a 'Reset password link' via email
version 0.001
{
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 ) };
};
};
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.
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 theupdate_user
method - update_user ( user, %params )
-
Should update the user object with %params. It is used for saving the new password and verification token.
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).
- call ( env )
Plack Plack::Middleware::Auth::Form
Zbigniew Lukasiak <zby@cpan.org>
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)