diff --git a/lib/NGCP/Panel.pm b/lib/NGCP/Panel.pm index 329f6ed14d..523db5ed8f 100644 --- a/lib/NGCP/Panel.pm +++ b/lib/NGCP/Panel.pm @@ -83,18 +83,6 @@ __PACKAGE__->config( }, 'Plugin::Authentication' => { - default => { - credential => { - class => 'Password', - password_field => 'password', - password_type => 'clear' - }, - store => { - class => 'Minimal', - users => { - } - } - }, reseller => { credential => { class => 'Password', @@ -122,6 +110,19 @@ __PACKAGE__->config( id_field => 'id', store_user_class => 'NGCP::Panel::AuthenticationStore::RoleFromRealm', } + }, + subscriber => { + credential => { + class => 'Password', + password_field => 'webpassword', + password_type => 'clear', + }, + store => { + class => 'DBIx::Class', + user_model => 'DB::provisioning_voip_subscribers', + id_field => 'id', + store_user_class => 'NGCP::Panel::AuthenticationStore::RoleFromRealm', + } } } ); diff --git a/lib/NGCP/Panel/AuthenticationStore/RoleFromRealm.pm b/lib/NGCP/Panel/AuthenticationStore/RoleFromRealm.pm index c3cb53157f..f66ba9e483 100644 --- a/lib/NGCP/Panel/AuthenticationStore/RoleFromRealm.pm +++ b/lib/NGCP/Panel/AuthenticationStore/RoleFromRealm.pm @@ -4,5 +4,9 @@ extends 'Catalyst::Authentication::Store::DBIx::Class::User'; sub roles { my ($self) = @_; + + if($self->auth_realm eq "subscriber" && $self->_user->admin) { + return "subscriberadmin"; + } return $self->auth_realm; } diff --git a/lib/NGCP/Panel/Controller/Login.pm b/lib/NGCP/Panel/Controller/Login.pm index c314d02c7e..1ba6d104e4 100644 --- a/lib/NGCP/Panel/Controller/Login.pm +++ b/lib/NGCP/Panel/Controller/Login.pm @@ -27,12 +27,8 @@ sub index :Path Form { my ( $self, $c, $realm ) = @_; $c->log->debug("*** Login::index"); -=pod $realm = 'subscriber' unless($realm and ($realm eq 'admin' or $realm eq 'reseller')); -=cut - $realm = 'admin' - unless($realm and ($realm eq 'reseller')); my $form = NGCP::Panel::Form::Login->new; $form->process( @@ -79,6 +75,21 @@ sub index :Path Form { } }, $realm); + } elsif($realm eq 'subscriber') { + # TODO: check for lock status? + $res = $c->authenticate( + { + webusername => $user, + webpassword => $pass, + 'dbix_class' => { + searchargs => [{ + -and => [ + webusername => $user, + ], + }], + } + }, + $realm); } if($res) { diff --git a/share/templates/login/login.tt b/share/templates/login/login.tt index 46b1bc2e52..e5574b908a 100644 --- a/share/templates/login/login.tt +++ b/share/templates/login/login.tt @@ -9,7 +9,7 @@
Go to [% - realms = ['admin', 'reseller']; + realms = ['subscriber', 'admin', 'reseller']; links = []; FOREACH r IN realms; UNLESS realm == r;