Skip to content

Commit

Permalink
registering users: the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
garu committed Jun 13, 2010
1 parent 04e44bf commit d16efb3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tweetylicious.pl
Expand Up @@ -43,6 +43,7 @@ package Model;
package main;

use Mojolicious::Lite;
use Mojo::ByteStream 'b'; # for unicode and md5

# this is a fake static route for our static data (static.js, static.css)
get '/static' => 'static';
Expand All @@ -52,8 +53,25 @@ package main;
get '/' => 'index';


# this controls a user registering
# these two control a user registering
get '/join' => 'join';
post '/join' => sub {
my $self = shift;
my $user = $self->param('username');

Model::User->create(
username => $user,
password => b(app->secret . $self->param('pwd'))->md5_sum,
email => $self->param('email'),
gravatar => b($self->param('email'))->md5_sum,
bio => $self->param('bio'),
);

# auto-login the user after he joins, and redirect to /
$self->session( name => $user );
$self->redirect_to("/");
} => 'join';



# let's rock and roll!
Expand Down

0 comments on commit d16efb3

Please sign in to comment.