# connecting with DBIx::Class { package My::Register; use parent 'WebPrototypes::Registration'; use Plack::Util::Accessor qw( schema ); sub find_user { my( $self, $name ) = @_; return $self->schema->resultset( 'User' )->search({ username => $name })->next; } sub create_user { my( $self, %fields ) = @_; return $self->schema->resultset( 'User' )->create({ %fields }); } } use Plack::Builder; my $app = My::Register->new( schema => $schema ); builder { mount "/register" => builder { $app->to_app; }; };
This application implements a user registration mechanism. After the registration and email address verification letter is sent.
The examples here are with DBIx::Class but they can be easily ported to other storage layers.
This application uses the Template Method design pattern.
These methods need to be overriden in subclass.
Should return a true value if the name is already registered
Should create the user object.
These methods have defaults - but should probably be overriden anyway.
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.
Should send the mail (created by build_mail).
Plack Plack::Middleware::Auth::Form
To install WebPrototypes::Registration, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebPrototypes::Registration
CPAN shell
perl -MCPAN -e shell install WebPrototypes::Registration
For more information on module installation, please visit the detailed CPAN module installation guide.