CGI-Application-Plugin-Authentication
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Authentication/Display/Basic.pm view on Meta::CPAN
my $tabindex = 3;
my ($rememberuser, $username_value, $register, $forgotpassword) = ('','','','');
if ($options{REMEMBERUSER_OPTION}) {
$rememberuser = <<END;
<label for="authen_rememberuserfield" id="authen_rememberuserfield_label" class="authen_label">$options{REMEMBERUSER_LABEL}
<input id="authen_rememberuserfield" class="authen_input" tabindex="$tabindex" type="checkbox" name="authen_rememberuser" value="1" />
</label>
END
$tabindex++;
$username_value = $self->_cgiapp->authen->_detaint_username($username, $options{REMEMBERUSER_COOKIENAME});
}
my $submit_tabindex = $tabindex++;
if ($options{REGISTER_URL}) {
$register = qq[<a href="$options{REGISTER_URL}" id="authen_registerlink" tabindex="$tabindex">$options{REGISTER_LABEL}</a>];
$tabindex++;
}
if ($options{FORGOTPASSWORD_URL}) {
$forgotpassword = qq[<a href="$options{FORGOTPASSWORD_URL}" id="authen_forgotpasswordlink" tabindex="$tabindex">$options{FORGOTPASSWORD_LABEL}</a>];
$tabindex++;
}
my $html .= <<END;
<form id="loginform" method="$options{FORM_SUBMIT_METHOD}" action="${action}">
<div class="login">
<div class="login_header">
$options{TITLE}
</div>
<div class="login_content">
<ul class="message">
${messages}
</ul>
<fieldset>
<label for="authen_loginfield" id="authen_loginfield_label" class="authen_label">$options{USERNAME_LABEL}
<input id="authen_loginfield" class="authen_input" tabindex="1" type="text" name="${username}" size="20" value="$username_value" />
</label>
<label for="authen_passwordfield" id="authen_passwordfield_label" class="authen_label">$options{PASSWORD_LABEL}
<input id="authen_passwordfield" class="authen_input" tabindex="2" type="password" name="${password}" size="20" />
</label>
${rememberuser}
</fieldset>
</div>
<div class="login_footer">
<div class="buttons">
<input id="authen_loginbutton" tabindex="${submit_tabindex}" type="submit" name="authen_loginbutton" value="$options{SUBMIT_LABEL}" class="button" />
${register}
${forgotpassword}
</div>
</div>
</div>
<input type="hidden" name="destination" value="${destination}" />
<input type="hidden" name="rm" value="${runmode}" />
</form>
END
return $html;
}
=head1 NAME
CGI::Application::Plugin::Authentication::Display::Basic - XHTML compliant no frills login display driver
=head1 DESCRIPTION
This module provides a login box that works out of the box but which can be
configured to modify the styling.
=head1 METHODS
=head2 new
The constructor must be passed the L<CGI::Application> object as the first
non-object argument.
=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.
Note that if somehow this method is run, whilst the user is authenticated,
it will croak.
You can set this option to customize the login form that is created when a user
needs to be authenticated. If you wish to replace the entire login form with a
completely custom version, then just set LOGIN_RUNMODE to point to your custom
runmode.
All of the parameters listed below are optional, and a reasonable default will
be used if left blank:
=over 4
=item TITLE (default: Sign In)
the heading at the top of the login box
=item USERNAME_LABEL (default: User Name)
the label for the user name input
=item PASSWORD_LABEL (default: Password)
the label for the password input
=item SUBMIT_LABEL (default: Sign In)
the label for the submit button
=item COMMENT (default: Please enter your username and password in the fields below.)
a message provided on the first login attempt
=item REMEMBERUSER_OPTION (default: 1)
provide a checkbox to offer to remember the users name in a cookie so that
their user name will be pre-filled the next time they log in
=item REMEMBERUSER_LABEL (default: Remember User Name)
the label for the remember user name checkbox
( run in 0.521 second using v1.01-cache-2.11-cpan-5a3173703d6 )