Move to single login page instead of seperate admin login
This commit is contained in:
parent
a78de6ea8e
commit
30c80679be
9 changed files with 143 additions and 131 deletions
|
@ -1,28 +1,16 @@
|
|||
package Pear::LocalLoop::Controller::Admin;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
sub index {
|
||||
my $c = shift;
|
||||
}
|
||||
|
||||
sub under {
|
||||
my $c = shift;
|
||||
|
||||
if ( $c->is_user_authenticated ) {
|
||||
return 1 if defined $c->current_user->administrator;
|
||||
}
|
||||
$c->redirect_to('/');
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub login {
|
||||
my $c = shift;
|
||||
|
||||
if ( $c->authenticate($c->param('email'), $c->param('password')) ) {
|
||||
$c->redirect_to('/admin/home');
|
||||
$c->redirect_to('/home');
|
||||
} else {
|
||||
$c->redirect_to('/admin');
|
||||
$c->redirect_to('/');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub home {
|
||||
|
|
|
@ -3,7 +3,26 @@ use Mojo::Base 'Mojolicious::Controller';
|
|||
|
||||
sub index {
|
||||
my $c = shift;
|
||||
}
|
||||
|
||||
sub under {
|
||||
my $c = shift;
|
||||
|
||||
if ( $c->is_user_authenticated ) {
|
||||
return 1;
|
||||
}
|
||||
$c->redirect_to('/');
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub auth_login {
|
||||
my $c = shift;
|
||||
|
||||
if ( $c->authenticate($c->param('email'), $c->param('password')) ) {
|
||||
$c->redirect_to('/home');
|
||||
} else {
|
||||
$c->redirect_to('/');
|
||||
}
|
||||
}
|
||||
|
||||
sub auth_logout {
|
||||
|
@ -13,5 +32,9 @@ sub auth_logout {
|
|||
$c->redirect_to('/');
|
||||
}
|
||||
|
||||
sub home {
|
||||
my $c = shift;
|
||||
$c->render(text => 'Root Home');
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue