Created
September 28, 2011 21:53
-
-
Save amiri/1249360 to your computer and use it in GitHub Desktop.
Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package RoosterPirates::Web::Controller::Login; | |
use Moose; | |
use namespace::autoclean; | |
BEGIN { extends 'Catalyst::Controller'; } | |
sub index : Chained('/') PathPart('login') Args('0') { | |
my ( $self, $c ) = @_; | |
$c->stash( template => 'login.tt2' ); | |
if ( lc $c->req->method eq 'post' ) { | |
my $email = $c->req->params->{email}; | |
my $password = $c->req->params->{password}; | |
if ( $c->authenticate( { email => $email, password => $password } ) ) | |
{ | |
$c->flash( | |
status_msg => "Welcome back, " . $c->user->first_name ); | |
return $c->res->redirect( | |
$c->uri_for( $c->controller('Root')->action_for('index') ) ); | |
} | |
else { | |
$c->stash( error_msg => "Bad username or password." ); | |
} | |
} | |
$c->stash( template => 'login.tt2' ); | |
} | |
__PACKAGE__->meta->make_immutable; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment