CGI-Application-Plugin-Authentication

 view release on metacpan or  search on metacpan

lib/CGI/Application/Plugin/Authentication/Display.pm  view on Meta::CPAN

    my $self = shift;
    return $self->_cgiapp->authen->is_authenticated;
}

sub  username {
    my $self = shift;
    return $self->_cgiapp->authen->username;
} 

sub  last_login {
    my $self = shift;
    return $self->_cgiapp->authen->last_login;
}

sub  last_access {
    my $self = shift;
	return $self->_cgiapp->authen->last_access;
}

sub  is_login_timeout  {
    my $self = shift;
	return $self->_cgiapp->authen->is_login_timeout;
}

sub  login_attempts {
    my $self = shift;
    return $self->_cgiapp->authen->login_attempts;
}

sub login_title {
     my $self = shift;
     my $login_options = $self->_cgiapp->authen->_config->{LOGIN_FORM} || {};
     return $login_options->{TITLE} || 'Sign In';
}


1; 

=head1 NAME

CGI::Application::Plugin::Authentication::Display - Generate bits of HTML needed for authentication

=head1 DESCRIPTION

The purpose of this code is to keep display code away from the back-end of
authentication management. It is an abstract base class and must be used 
in conjunction with derived classes. Those derived classes can be used
in an number of ways:

=over

=item

The subclass L<CGI::Application::Plugin::Authentication::Display::Classic>
is provided to ensure backwards compatibility with the old code. It has 
the advantage of working out of the box but still retaining flexibility.

=item

The subclass L<CGI::Application::Plugin::Authentication::Display::Basic>
is provided to ensure XHTML compliance and to leave styling to CSS style-sheets.

=item

You can handle all the HTML side yourself in which case this code is not even loaded.

=item 

You can use derived classes in templates that have dot support, which keeps
the display code close to the templates. This has other advantages. For example
one can use the C<enforce_protection> method to mark a template as being 
only viewable after authentication. A number of other methods can be called 
from the template that provide information about the authentication status.

=back

=head1 METHODS

=head2 new 

The constructor must be passed the L<CGI::Application> object as the first
non-object argument.  This allows derived modules to access the
authentication information.

=head2 login_box

This method will return the HTML for a login box that can be
embedded into another page.  This is the same login box that is used
in the default authen_login runmode that the plugin provides.

This function is not implemented in this module. One must use a derived class
with an appropriate implementation of this function.

=head2 logout_form

This returns the simple bit of HTML need to have a logout button. The form
has '/?authen_logout=1' as the action but of course this can be changed in
derived modules.

=head2 enforce_protection

This method is useful when the class is being used in templates to mark a
certain template as for authenticated eyes only. So in
L<HTML::Template::Plugin::Dot> one might have

    <TMPL_VAR NAME="authen.enforce_protection">
    
and one must set C<authen> to one of these objects via the
C<HTML::Template::param> method. If authenticated it will resolve to a 
simple string, otherwise it will croak.

=head2 login_title

This returns the I<TITLE> parameter from the I<LOGIN_FORM> section of the config.

=head2 is_authenticated 

=head2 username 

=head2 last_login



( run in 1.025 second using v1.01-cache-2.11-cpan-e93a5daba3e )