From 76e9d458d47e5a422a2af4556a40d20d2c44fc93 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Mon, 25 Feb 2013 09:52:51 +0100 Subject: [PATCH] Add basic error handling. Will be rebuilt using formhandler. --- debian/ngcp-panel.copyright | 11 +++++++++++ lib/NGCP/Panel.pm | 2 +- lib/NGCP/Panel/Controller/Login.pm | 19 +++++++++++-------- share/templates/login.tt | 5 +++++ 4 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 debian/ngcp-panel.copyright diff --git a/debian/ngcp-panel.copyright b/debian/ngcp-panel.copyright new file mode 100644 index 0000000000..c7c92aaff4 --- /dev/null +++ b/debian/ngcp-panel.copyright @@ -0,0 +1,11 @@ +The design is based on "Dashboard Admin" copyright 2012 http://jumpstartui.com/. +An Extended License has been purchased from here: + https://wrapbootstrap.com/theme/dashboard-admin-WB0164888?l=e + +The license details are as follows: + +Item: Dashboard Admin (Extended License) +Item#: WB0164888 +License: Extended License +License ID: 9890cae9-cadf-4b2a-9c86-840570356df5 + diff --git a/lib/NGCP/Panel.pm b/lib/NGCP/Panel.pm index 6ab356ce65..95ef442e1b 100644 --- a/lib/NGCP/Panel.pm +++ b/lib/NGCP/Panel.pm @@ -65,7 +65,7 @@ __PACKAGE__->config( session => { flash_to_stash => 1, expires => 3600, - }, + }, 'Plugin::Authentication' => { default => { diff --git a/lib/NGCP/Panel/Controller/Login.pm b/lib/NGCP/Panel/Controller/Login.pm index 79d26a0c61..fa58f78e13 100644 --- a/lib/NGCP/Panel/Controller/Login.pm +++ b/lib/NGCP/Panel/Controller/Login.pm @@ -1,7 +1,7 @@ package NGCP::Panel::Controller::Login; + use Moose; use namespace::autoclean; - BEGIN { extends 'Catalyst::Controller'; } =head1 NAME @@ -21,18 +21,18 @@ Catalyst Controller. =cut -sub index :Path { +sub index :Path Form { my ( $self, $c, $realm ) = @_; $c->log->debug("*** Login::index"); - - my $user = $c->req->params->{username}; - my $pass = $c->req->params->{password}; - $realm = 'subscriber' unless($realm and ($realm eq 'admin' or $realm eq 'reseller')); - if($user and $pass) { + my $user = $c->request->param('username'); + my $pass = $c->request->param('password'); + $c->log->debug("*** Login::index user=$user, pass=$pass, realm=$realm"); + + if($user && $pass) { $c->log->debug("*** Login::index user=$user, pass=$pass, realm=$realm"); if($c->authenticate({ username => $user, password => $pass }, $realm)) { # auth ok @@ -42,9 +42,12 @@ sub index :Path { $c->response->redirect($target); } else { $c->log->debug("*** Login::index auth failed"); + $c->stash->{error}->{message} = 'login failed'; } } else { - $c->log->debug("*** Login::index incomplete creds"); + if($user || $pass) { + $c->stash->{error}->{message} = 'invalid form'; + } } $c->stash(realm => $realm); diff --git a/share/templates/login.tt b/share/templates/login.tt index 6f1803bcf1..fa23735a98 100644 --- a/share/templates/login.tt +++ b/share/templates/login.tt @@ -1,4 +1,9 @@ + [% IF error.message -%] +
+ [% error.message -%] +
+ [% END -%]