Update login helper to return a hashref

master
Daniel Berteaud 10 years ago
parent 798102117e
commit b5d483645c
  1. 13
      vroom.pl

@ -84,13 +84,24 @@ plugin mail => {
# Create a cookie based session # Create a cookie based session
helper login => sub { helper login => sub {
my $self = shift; my $self = shift;
return if $self->session('name'); my $ret = {
status => undef,
msg => undef
};
if ($self->session('name')){
$ret->{status} = 1;
$ret->{msg} = 'ALREADY_LOGGED';
return $ret;
}
my $login = $ENV{'REMOTE_USER'} || lc $self->get_random(256); my $login = $ENV{'REMOTE_USER'} || lc $self->get_random(256);
$self->session( $self->session(
name => $login, name => $login,
ip => $self->tx->remote_address ip => $self->tx->remote_address
); );
$self->app->log->info($self->session('name') . " logged in from " . $self->tx->remote_address); $self->app->log->info($self->session('name') . " logged in from " . $self->tx->remote_address);
$ret->{status} = 1;
$ret->{msg} = 'LOGIN_SUCCESS';
return $ret;
}; };
# Expire the cookie # Expire the cookie

Loading…
Cancel
Save