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(@_);
|
my $return = $self->SUPER::install(@_);
|
||||||
$return = [ split /\n/, $return ];
|
$return = [ split /\n/, $return ];
|
||||||
for my $i ( keys @$return ) {
|
for my $i ( keys @$return ) {
|
||||||
$return->[$i] .= ' install_frontend_and_migrations'
|
$return->[$i] =~ s/::/:: install_frontend_and_migrations/
|
||||||
if $return->[$i] =~ /^install :/;
|
if $return->[$i] =~ /^install :/;
|
||||||
}
|
}
|
||||||
return join "\n", @$return;
|
return join "\n", @$return;
|
||||||
|
@ -14,6 +14,8 @@ sub GetLogin {
|
|||||||
|
|
||||||
sub Login {
|
sub Login {
|
||||||
my $self = shift;
|
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 $user_manager = BeastBB::DAO::UserManager->new( app => $self );
|
||||||
my $username = $self->param('username');
|
my $username = $self->param('username');
|
||||||
my $password = $self->param('password');
|
my $password = $self->param('password');
|
||||||
@ -21,7 +23,7 @@ sub Login {
|
|||||||
return $self->reply->exception('Request not understood.')->rendered(400)
|
return $self->reply->exception('Request not understood.')->rendered(400)
|
||||||
if !defined $username || !defined $password;
|
if !defined $username || !defined $password;
|
||||||
my $maybe_user = $user_manager->Get( username => $username );
|
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)
|
return $self->redirect_to($error_url)
|
||||||
if $maybe_user->IsError
|
if $maybe_user->IsError
|
||||||
|| !$maybe_user->Content->CheckPasswordLogin( password => $password );
|
|| !$maybe_user->Content->CheckPasswordLogin( password => $password );
|
||||||
|
@ -9,12 +9,13 @@ use Mojo::Base 'BeastBB::Controller';
|
|||||||
|
|
||||||
sub Index {
|
sub Index {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $error = $self->param('error');
|
||||||
my $maybe_logged_in_user = $self->LoggedUser;
|
my $maybe_logged_in_user = $self->LoggedUser;
|
||||||
print Data::Dumper::Dumper $maybe_logged_in_user;
|
|
||||||
if ( $maybe_logged_in_user->IsError ) {
|
if ( $maybe_logged_in_user->IsError ) {
|
||||||
delete $self->session->{username}
|
delete $self->session->{username}
|
||||||
if $maybe_logged_in_user =~ qr/No such user found\./;
|
if $maybe_logged_in_user =~ qr/No such user found\./;
|
||||||
}
|
}
|
||||||
|
$self->stash( error => $error );
|
||||||
$self->stash(
|
$self->stash(
|
||||||
user => !$maybe_logged_in_user->IsError
|
user => !$maybe_logged_in_user->IsError
|
||||||
? $maybe_logged_in_user->Content
|
? $maybe_logged_in_user->Content
|
||||||
|
@ -2,3 +2,6 @@
|
|||||||
% if (!defined $user) {
|
% if (!defined $user) {
|
||||||
<p><a href="/login">Login</a> <a href="/signup">Signup</a>
|
<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