Supporting error printing on Index
This commit is contained in:
parent
03bc585b9c
commit
c3584056b4
@ -15,7 +15,7 @@ package MY {
|
||||
my $return = $self->SUPER::install(@_);
|
||||
$return = [ split /\n/, $return ];
|
||||
for my $i ( keys @$return ) {
|
||||
$return->[$i] .= ' install_frontend_and_migrations'
|
||||
$return->[$i] =~ s/::/:: install_frontend_and_migrations/
|
||||
if $return->[$i] =~ /^install :/;
|
||||
}
|
||||
return join "\n", @$return;
|
||||
|
@ -14,6 +14,8 @@ sub GetLogin {
|
||||
|
||||
sub Login {
|
||||
my $self = shift;
|
||||
my $error_url = Mojo::URL->new('/')->query( error => 'You are already logged in.');
|
||||
return $self->redirect_to($error_url) if !$self->LoggedUser->IsError;
|
||||
my $user_manager = BeastBB::DAO::UserManager->new( app => $self );
|
||||
my $username = $self->param('username');
|
||||
my $password = $self->param('password');
|
||||
@ -21,7 +23,7 @@ sub Login {
|
||||
return $self->reply->exception('Request not understood.')->rendered(400)
|
||||
if !defined $username || !defined $password;
|
||||
my $maybe_user = $user_manager->Get( username => $username );
|
||||
my $error_url = Mojo::URL->new('/')->query( error => $wrong_auth_error );
|
||||
$error_url = Mojo::URL->new('/')->query( error => $wrong_auth_error );
|
||||
return $self->redirect_to($error_url)
|
||||
if $maybe_user->IsError
|
||||
|| !$maybe_user->Content->CheckPasswordLogin( password => $password );
|
||||
|
@ -9,12 +9,13 @@ use Mojo::Base 'BeastBB::Controller';
|
||||
|
||||
sub Index {
|
||||
my $self = shift;
|
||||
my $error = $self->param('error');
|
||||
my $maybe_logged_in_user = $self->LoggedUser;
|
||||
print Data::Dumper::Dumper $maybe_logged_in_user;
|
||||
if ( $maybe_logged_in_user->IsError ) {
|
||||
delete $self->session->{username}
|
||||
if $maybe_logged_in_user =~ qr/No such user found\./;
|
||||
}
|
||||
$self->stash( error => $error );
|
||||
$self->stash(
|
||||
user => !$maybe_logged_in_user->IsError
|
||||
? $maybe_logged_in_user->Content
|
||||
|
@ -2,3 +2,6 @@
|
||||
% if (!defined $user) {
|
||||
<p><a href="/login">Login</a> <a href="/signup">Signup</a>
|
||||
% }
|
||||
% if (defined $error) {
|
||||
<p style="color: red;"><%= $error %></p>
|
||||
% }
|
||||
|
Loading…
Reference in New Issue
Block a user