CatalystX-Controller-Auth
view release on metacpan or search on metacpan
lib/CatalystX/Controller/Auth.pm view on Meta::CPAN
package CatalystX::Controller::Auth;
use 5.006;
use strict;
use warnings;
=head1 NAME
CatalystX::Controller::Auth - A config-driven Catalyst authentication controller base class.
=head1 VERSION
Version 0.22
=cut
our $VERSION = '0.22';
$VERSION = eval $VERSION;
use Moose;
use namespace::autoclean;
use HTML::FormHandlerX::Form::Login;
has form_handler => ( is => 'ro', isa => 'Str', default => 'HTML::FormHandlerX::Form::Login' );
has view => ( is => 'ro', isa => 'Str', default => 'TT' );
has realm => ( is => 'ro', isa => 'Str', default => 'default' );
has login_fields => ( is => 'ro', isa => 'HashRef', default => sub { { default => [ qw(username password) ] } } );
has login_id_field => ( is => 'ro', isa => 'Str', default => 'username' );
has login_id_db_field => ( is => 'ro', isa => 'Str', default => 'username' );
has db_id_field => ( is => 'ro', isa => 'Str', default => 'id' );
has enable_register => ( is => 'ro', isa => 'Bool', default => 1 );
has enable_sending_register_email => ( is => 'ro', isa => 'Bool', default => 1 );
has register_template => ( is => 'ro', isa => 'Str', default => 'auth/register.tt' );
has login_template => ( is => 'ro', isa => 'Str', default => 'auth/login.tt' );
has change_password_template => ( is => 'ro', isa => 'Str', default => 'auth/change-password.tt' );
has forgot_password_template => ( is => 'ro', isa => 'Str', default => 'auth/forgot-password.tt' );
has reset_password_template => ( is => 'ro', isa => 'Str', default => 'auth/reset-password.tt' );
has register_successful_message => ( is => 'ro', isa => 'Str', default => "You are now registered." );
has register_exists_failed_message => ( is => 'ro', isa => 'Str', default => "That username already exists." );
has login_required_message => ( is => 'ro', isa => 'Str', default => "You need to login." );
has already_logged_in_message => ( is => 'ro', isa => 'Str', default => "You are already logged in." );
has login_successful_message => ( is => 'ro', isa => 'Str', default => "You have logged in." );
has logout_successful_message => ( is => 'ro', isa => 'Str', default => "You have been logged out." );
has login_failed_message => ( is => 'ro', isa => 'Str', default => "Bad username or password." );
has password_changed_message => ( is => 'ro', isa => 'Str', default => "Password changed." );
has password_reset_message => ( is => 'ro', isa => 'Str', default => "Password reset successfully." );
has forgot_password_id_unknown => ( is => 'ro', isa => 'Str', default => "Email address not registered." );
has auto_login_after_register => ( is => 'ro', isa => 'Bool', default => 1 );
has action_after_register => ( is => 'ro', isa => 'Str', );
has action_after_login => ( is => 'ro', isa => 'Str', );
has action_after_change_password => ( is => 'ro', isa => 'Str', );
has email_stash_key => ( is => 'ro', isa => 'Str', default => 'email_template' );
has forgot_password_email_view => ( is => 'ro', isa => 'Str', default => 'Email::Template' );
has forgot_password_email_from => ( is => 'ro', isa => 'Str', default => 'nobody@localhost' );
has forgot_password_email_subject => ( is => 'ro', isa => 'Str', default => 'Forgot Password' );
has forgot_password_email_template_plain => ( is => 'ro', isa => 'Str', default => 'reset-password-plain.tt' );
has register_email_view => ( is => 'ro', isa => 'Str', default => 'Email::Template' );
has register_email_from => ( is => 'ro', isa => 'Str', default => 'nobody@localhost' );
has register_email_subject => ( is => 'ro', isa => 'Str', default => 'Registration Success' );
has register_email_template_plain => ( is => 'ro', isa => 'Str', default => 'register-plain.tt' );
has token_salt => ( is => 'ro', isa => 'Str', default => "abc123" );
BEGIN { extends 'Catalyst::Controller'; }
=head1 SYNOPSIS
This is a Catalyst controller for handling registering, logging in/out, forgotten/resetting passwords, and changing passwords.
This controller was essentially born out of L<HTML::FormHandlerX::Form::Login> (which it uses), though
that form does not want to become dependant on Catalyst.
See L<CatalystX::SimpleLogin> for an alternative approach.
Ensure you include the L<Catalyst::Plugin::StatusMessage> in MyApp.pm.
use Catalyst qw/
...
( run in 1.970 second using v1.01-cache-2.11-cpan-39bf76dae61 )