TT#124275 Add 'Login to CSC' button in subscriber page

* upon pressing the button, a new session object
	    with selected subscriber's details will be inserted
	    in Redis, and also a new ngcp-panel_subscriber
	    cookie will be created containing the session id
	    of the previously created session object; then
	    the user will be redirected to CSC v1 address
	    where the selected subscriber will be authenticated
	    based on the cookie and Redis info
	  * the new button will be available for admin,
	    reseller, ccare and ccareadmin roles

Change-Id: I03952efe4abe18e61884859c466d700a7885ead4
mr9.5.1
Flaviu Mates 4 years ago
parent f8ce039b15
commit e09c478ee1

@ -123,6 +123,7 @@ __PACKAGE__->config(
expires => 3600,
cookie_secure => 1,
cookie_name => 'ngcp-panel',
login_to_csc_session_expiry => 86400, #24 hours expiry for subscriber sessions created directly from Admin UI
},
'Plugin::Authentication' => {

@ -3161,6 +3161,29 @@ sub edit_master :Chained('master') :PathPart('edit') :Args(0) :Does(ACL) :ACLDet
}
sub login_to_csc :Chained('master') :PathPart('login_to_csc') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) :AllowedRole(ccareadmin) :AllowedRole(ccare) {
my ($self, $c) = @_;
$c->detach('/denied_page') if($c->user->read_only);
my $subscriber = $c->stash->{subscriber};
my $prov_subscriber = $subscriber->provisioning_voip_subscriber;
#create a new subscriber session and then store it to Redis
#realm and user are enough here, as user_tz and language will be automatically filled on redirection
my $subscriber_session = {};
$subscriber_session->{__user_realm} = 'subscriber';
$subscriber_session->{__user} = { $prov_subscriber->get_inflated_columns };
my $new_sid = $c->generate_session_id();
$c->store_session_data( "session:$new_sid" => $subscriber_session );
my $new_session_expiry = $c->_session_plugin_config->{login_to_csc_session_expiry} // 3600;
$c->store_session_data( "expires:$new_sid" => time + $new_session_expiry );
$c->response->cookies->{'ngcp-panel_subscriber'} = { 'value' => $new_sid };
#redirect to server's hostname
$c->res->redirect("https://" . $c->req->uri->host . "/");
}
sub order_pbx_items :Chained('master') :PathPart('orderpbxitems') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) : AllowedRole(reseller) :AllowedRole(ccareadmin) :AllowedRole(ccare) :AllowedRole(subscriberadmin) {
my ($self, $c) = @_;

@ -54,6 +54,10 @@
END;
-%]
<a class="btn btn-primary btn-large" href="[% href %]"><i class="icon-edit"></i> [% c.loc('Edit') %]</a>
[% IF (c.user.roles == "admin" || c.user.roles == "reseller" ||
c.user.roles == "ccareadmin" || c.user.roles == "ccare") -%]
<a class="btn btn-primary btn-large" href="[% c.uri_for_action('/subscriber/login_to_csc', [ subscriber.id ]) %]" target="_blank"><i class="icon-user"></i> [% c.loc('Login to CSC') %]</a>
[% END -%]
[% END -%]
[% IF subscriber.contract.passreset_email_template -%]
<a class="btn btn-secondary btn-large" href="[% c.uri_for_action('/subscriber/reset_webpassword', [subscriber.id]) %]" data-confirm="Reset"><i class="icon-repeat"></i> [% c.loc('Reset Web Password') %]</a>

Loading…
Cancel
Save