Rubric::WebApp::Login::Post - process web login from query parameters


Rubric documentation Contained in the Rubric distribution.

Index


Code Index:

NAME

Top

Rubric::WebApp::Login::Post - process web login from query parameters

VERSION

Top

version 0.147

DESCRIPTION

Top

This module checks the submitted query for information needed to confirm that a user is logged into the Rubric.

METHODS

Top

get_login_username

This checks for the username in a current login request. First it checks whether there is a current_user value in this session. If not, it looks for a user query parameter.

authenticate_login($webapp, $user)

This returns true if the username came from the session. Otherwise, it checks for a password query parameter and compares its md5sum against the user's stored password md5sum.

set_current_user($webapp, $user)

This method sets the current user in the session and then calls the superclass set_current_user.

AUTHOR

Top

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-rubric@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Top


Rubric documentation Contained in the Rubric distribution.
use strict;
use warnings;
package Rubric::WebApp::Login::Post;
use base qw(Rubric::WebApp::Login);

use Digest::MD5 qw(md5_hex);

our $VERSION = '0.147';

sub get_login_username {
	my ($class, $webapp) = @_;

	$webapp->session->param('current_user') || $webapp->query->param('user');
}

sub authenticate_login {
	my ($self, $webapp, $user) = @_;
	
	return 1 if
		$webapp->session->param('current_user') and
		$webapp->session->param('current_user') eq $user;

	my $password = $webapp->query->param('password');

	return (md5_hex($password) eq $user->password);
}

sub set_current_user {
	my ($self, $webapp, $user) = @_;

	$webapp->session->param(current_user => $user->username);
	$self->SUPER::set_current_user($webapp, $user);
}

1;