Permalink
Browse files

user login: the controller (handling form submission)

  • Loading branch information...
1 parent f73b8f2 commit 7035cf787a6b36c63a012e82ff0c1163a00b695c @garu committed Jun 13, 2010
Showing with 12 additions and 0 deletions.
  1. +12 −0 tweetylicious.pl
View
@@ -96,6 +96,18 @@ package main;
# user login
get '/login' => 'login';
+post '/login' => sub {
+ my $self = shift;
+ my $user = $self->param('username') || '';
+
+ if ( Model::User->count( 'WHERE username=? AND password=?',
+ $user, b(app->secret . $self->param('password'))->md5_sum) == 1
+ ) {
+ $self->session( name => $user );
+ return $self->redirect_to("/");
+ }
+ $self->stash( error => 1 );
+} => 'login';
# let's rock and roll!

0 comments on commit 7035cf7

Please sign in to comment.