nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / services / support / session / session.service.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20
21 'use strict';
22
23 (function () {
24     class SessionService {
25         constructor($q, $log, $http, conf,uuid,$sce) {
26             this.$q = $q;
27             this.$log = $log;
28             this.$http = $http;
29             this.conf = conf;
30             this.uuid = uuid;
31             this.$sce = $sce;
32         }
33         
34         logout(appStr) {
35             this.$log.info('SessionService::logout from App');
36             let deferred = this.$q.defer();
37             this.$log.info('SessionService appStr: ', appStr);
38            
39                         var eaccessPattern = '\https?\:\/\/[^/]+/[^/]+/[^/]+';
40             var standardPattern = '\https?\:\/\/[^/]+/[^/]+';
41             
42             if(appStr.includes("e-access")) {
43                 standardPattern = eaccessPattern;
44             }
45                 
46             var contextUrl = appStr.match(new RegExp(standardPattern));
47             var logoutUrl  = contextUrl + "/logout.htm" ;
48             this.$sce.trustAsResourceUrl(logoutUrl);
49                         console.log('logoutUrl ' + logoutUrl);
50                         jQuery('#reg-logout-div').append("<iframe style='display:none' src='" + logoutUrl + "' />");
51         }
52
53     }
54     SessionService.$inject = ['$q', '$log', '$http', 'conf','uuid4','$sce'];
55     angular.module('ecompApp').service('sessionService', SessionService)
56 })();