From f7f67f5aec903103ee55e6e75a4532520871e6b6 Mon Sep 17 00:00:00 2001 From: NKOKKILIGADDA87 Date: Fri, 13 Dec 2024 12:28:06 +0530 Subject: [PATCH] 1097 session storage wasa changes --- .../dashboardUserId.component.ts | 20 ++-- src/app/innerpage/innerpage.component.ts | 74 ++++++------- src/app/login/login.component.ts | 39 +++++-- .../multi-role-screen.component.ts | 59 ++++++----- .../authGuardService/auth-guard.services.ts | 5 +- src/app/services/config/config.service.ts | 24 ++--- src/app/services/czentrix/czentrix.service.ts | 11 +- .../services/loginService/login.service.ts | 12 ++- .../session-storage.service.ts | 100 ++++++++++++++++++ src/environments/enckey.ts | 4 + src/environments/environment.prod.ts | 5 +- src/environments/environment.ts | 5 +- 12 files changed, 248 insertions(+), 110 deletions(-) create mode 100644 src/app/services/sessionStorageService/session-storage.service.ts create mode 100644 src/environments/enckey.ts diff --git a/src/app/dashboard-user-id/dashboardUserId.component.ts b/src/app/dashboard-user-id/dashboardUserId.component.ts index 07e26df5..1515ba12 100644 --- a/src/app/dashboard-user-id/dashboardUserId.component.ts +++ b/src/app/dashboard-user-id/dashboardUserId.component.ts @@ -31,6 +31,7 @@ import { Subscription } from "rxjs/Subscription"; import { CallServices } from "app/services/callservices/callservice.service"; import { SetLanguageComponent } from "app/set-language.component"; import { HttpServices } from "app/services/http-services/http_services.service"; +import { sessionStorageService } from "app/services/sessionStorageService/session-storage.service"; @Component({ selector: "dashboard-user-id", @@ -45,6 +46,7 @@ export class DashboardUserIdComponent implements OnInit { constructor( public dataSettingService: dataService, public router: Router, + private sessionstorage:sessionStorageService, private callService: CallServices, private Czentrix: CzentrixServices, private message: ConfirmationDialogsService, @@ -80,10 +82,10 @@ export class DashboardUserIdComponent implements OnInit { if ( !this.dataSettingService.current_campaign && - sessionStorage.getItem("current_campaign") + this.sessionstorage.getItem("current_campaign") ) { this.dataSettingService.current_campaign = - sessionStorage.getItem("current_campaign"); + this.sessionstorage.getItem("current_campaign"); } if (res.data.dialer_type) { if (res.data.dialer_type.toUpperCase() == "PROGRESSIVE") { @@ -120,7 +122,7 @@ export class DashboardUserIdComponent implements OnInit { .switchToOutbound(this.dataSettingService.cZentrixAgentID) .subscribe( (response) => { - sessionStorage.setItem("current_campaign", "OUTBOUND"); + this.sessionstorage.setItem("current_campaign", "OUTBOUND"); this.callService.onceOutbound = true; this.callService.onlyOutbound = false; this.timerSubscription.unsubscribe(); @@ -128,7 +130,7 @@ export class DashboardUserIdComponent implements OnInit { }, (err) => { console.log("agent in not logged in"); - sessionStorage.setItem("current_campaign", "OUTBOUND"); + this.sessionstorage.setItem("current_campaign", "OUTBOUND"); } ); } @@ -146,10 +148,10 @@ export class DashboardUserIdComponent implements OnInit { this.status.toUpperCase() === "INCALL" || this.status.toUpperCase() === "CLOSURE" ) { - if (!sessionStorage.getItem("session_id")) { + if (!this.sessionstorage.getItem("session_id")) { this.routeToInnerPage(res); } else if ( - sessionStorage.getItem("session_id") !== res.session_id + this.sessionstorage.getItem("session_id") !== res.session_id ) { // If session id is different from previous session id then allow the call to drop this.routeToInnerPage(res); @@ -176,9 +178,9 @@ export class DashboardUserIdComponent implements OnInit { session_id !== "undefined" && session_id !== "" ) { - sessionStorage.setItem("isOnCall", "yes"); - sessionStorage.setItem("CLI", CLI); - sessionStorage.setItem("session_id", session_id); + this.sessionstorage.setItem("isOnCall", "yes"); + this.sessionstorage.setItem("CLI", CLI); + this.sessionstorage.setItem("session_id", session_id); this.dataSettingService.setUniqueCallIDForInBound = true; this.router.navigate([ "/MultiRoleScreenComponent/RedirectToInnerpageComponent", diff --git a/src/app/innerpage/innerpage.component.ts b/src/app/innerpage/innerpage.component.ts index d394dff2..a84fb0e4 100644 --- a/src/app/innerpage/innerpage.component.ts +++ b/src/app/innerpage/innerpage.component.ts @@ -46,6 +46,7 @@ import { AuthService } from "../services/authentication/auth.service"; import { RegisterService } from "../services/register-services/register-service"; import { Subscription } from "rxjs/Subscription"; import { SetLanguageComponent } from "app/set-language.component"; +import { sessionStorageService } from "app/services/sessionStorageService/session-storage.service"; declare const jQuery: any; @@ -120,6 +121,7 @@ export class InnerpageComponent implements OnInit { current_roleID: any; constructor( + private sessionstorage:sessionStorageService, public getCommonData: dataService, private _callServices: CallServices, public basicrouter: Router, @@ -173,11 +175,11 @@ export class InnerpageComponent implements OnInit { this.ctiHandlerURL = this.sanitizer.bypassSecurityTrustResourceUrl(url); console.log("url = " + url); this.ctiHandlerURL = this.sanitizer.bypassSecurityTrustResourceUrl(url); - if (sessionStorage.getItem("CLI") !== undefined) { - this.callerNumber = sessionStorage.getItem("CLI"); + if (this.sessionstorage.getItem("CLI") !== undefined) { + this.callerNumber = this.sessionstorage.getItem("CLI"); } - if (sessionStorage.getItem("callCategory") !== undefined) { - if (sessionStorage.getItem("callCategory") === "OUTBOUND") { + if (this.sessionstorage.getItem("callCategory") !== undefined) { + if (this.sessionstorage.getItem("callCategory") === "OUTBOUND") { this.getCommonData.isOutbound = true; } else { this.getCommonData.isOutbound = false; @@ -219,7 +221,7 @@ export class InnerpageComponent implements OnInit { // this.addListener(); this.getAgentStatus(); this.getAgentCallDetails(); - this.isEverwell = sessionStorage.getItem("isEverwellCall"); + this.isEverwell = this.sessionstorage.getItem("isEverwellCall"); this.fetchLanguageSet(); } @@ -463,11 +465,11 @@ export class InnerpageComponent implements OnInit { ); } else { this.ipSuccessLogoutHandler(this.getCommonData.loginIP); - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); // this.basicrouter.navigate(['']); // this.authService.removeToken(); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem("setLanguage"); // this.getCommonData.appLanguage="English"; } } @@ -497,20 +499,20 @@ export class InnerpageComponent implements OnInit { if (this.current_role.toLowerCase() === "supervisor") { this.Czentrix.userLogout().subscribe( (response) => { - sessionStorage.removeItem("isOnCall"); - sessionStorage.removeItem("isEverwellCall"); - sessionStorage.removeItem("apiman_key"); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("isOnCall"); + this.sessionstorage.removeItem("isEverwellCall"); + this.sessionstorage.removeItem("apiman_key"); + this.sessionstorage.removeItem("setLanguage"); this.authService.removeToken(); this.getCommonData.appLanguage = "English"; this.basicrouter.navigate([""]); // this.socketService.logOut(); }, (err) => { - sessionStorage.removeItem("isOnCall"); - sessionStorage.removeItem("isEverwellCall"); - sessionStorage.removeItem("apiman_key"); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("isOnCall"); + this.sessionstorage.removeItem("isEverwellCall"); + this.sessionstorage.removeItem("apiman_key"); + this.sessionstorage.removeItem("setLanguage"); this.authService.removeToken(); this.getCommonData.appLanguage = "English"; this.basicrouter.navigate([""]); @@ -526,20 +528,20 @@ export class InnerpageComponent implements OnInit { if (res.response.status.toUpperCase() !== "FAIL") { this.Czentrix.userLogout().subscribe( (response) => { - sessionStorage.removeItem("isOnCall"); - sessionStorage.removeItem("isEverwellCall"); - sessionStorage.removeItem("apiman_key"); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("isOnCall"); + this.sessionstorage.removeItem("isEverwellCall"); + this.sessionstorage.removeItem("apiman_key"); + this.sessionstorage.removeItem("setLanguage"); this.authService.removeToken(); this.getCommonData.appLanguage = "English"; this.basicrouter.navigate([""]); // this.socketService.logOut(); }, (err) => { - sessionStorage.removeItem("isOnCall"); - sessionStorage.removeItem("isEverwellCall"); - sessionStorage.removeItem("apiman_key"); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("isOnCall"); + this.sessionstorage.removeItem("isEverwellCall"); + this.sessionstorage.removeItem("apiman_key"); + this.sessionstorage.removeItem("setLanguage"); this.getCommonData.appLanguage = "English"; this.authService.removeToken(); this.basicrouter.navigate([""]); @@ -561,9 +563,9 @@ export class InnerpageComponent implements OnInit { // if (this.current_role.toLowerCase() !== 'supervisor') { // this.Czentrix.agentLogout(this.getCommonData.cZentrixAgentID, response).subscribe((res) => { // if (res.response.status.toUpperCase() !== 'FAIL') { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem("setLanguage"); // this.getCommonData.appLanguage="English"; // this.basicrouter.navigate(['']); // } else { @@ -575,9 +577,9 @@ export class InnerpageComponent implements OnInit { // this.remarksMessage.alert(err.errorMessage); // }); // } else { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem("setLanguage"); // this.getCommonData.appLanguage="English"; // this.basicrouter.navigate(['']); // } @@ -798,13 +800,13 @@ export class InnerpageComponent implements OnInit { requestObj["agentID"] = this.getCommonData.cZentrixAgentID; requestObj["endCall"] = true; } - if (sessionStorage.getItem("session_id") === this.custdisconnectCallID) { + if (this.sessionstorage.getItem("session_id") === this.custdisconnectCallID) { this._callServices.closeCall(requestObj).subscribe( (response) => { if (response) { this.remarksMessage.alert(message, "success"); - sessionStorage.removeItem("isOnCall"); - sessionStorage.removeItem("isEverwellCall"); + this.sessionstorage.removeItem("isOnCall"); + this.sessionstorage.removeItem("isEverwellCall"); this.basicrouter.navigate(["/MultiRoleScreenComponent/dashboard"]); this._common.everwellCallNotConnected = null; } @@ -983,8 +985,8 @@ export class InnerpageComponent implements OnInit { } getLanguage() { - if (sessionStorage.getItem("setLanguage") != null) { - this.changeLanguage(sessionStorage.getItem("setLanguage")); + if (this.sessionstorage.getItem("setLanguage") != null) { + this.changeLanguage(this.sessionstorage.getItem("setLanguage")); } else { this.changeLanguage(this.app_language); } @@ -1014,7 +1016,7 @@ export class InnerpageComponent implements OnInit { } console.log("language is ", response); this.currentLanguageSet = response[language]; - sessionStorage.setItem("setLanguage", language); + this.sessionstorage.setItem("setLanguage", language); if (this.currentLanguageSet) { this.languageArray.forEach((item) => { if (item.languageName === language) { diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 2a66f907..42a38424 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -32,6 +32,7 @@ import { Subscription } from 'rxjs'; import { InterceptedHttp } from 'app/http.interceptor'; // import { SHA256, enc } from 'crypto-js'; import * as CryptoJS from 'crypto-js'; +import { sessionStorageService } from 'app/services/sessionStorageService/session-storage.service'; // import { AES } from 'crypto-js'; // import { SHA256 } from 'crypto-js'; @@ -69,7 +70,7 @@ export class loginContentClass implements OnInit, OnDestroy { previlageObj: any = []; encryptPassword: any; - constructor(public loginservice: loginService, public router: Router, public alertService: ConfirmationDialogsService, + constructor(public loginservice: loginService,private sessionstorage:sessionStorageService, public router: Router, public alertService: ConfirmationDialogsService, public dataSettingService: dataService, private czentrixServices: CzentrixServices, private socketService: SocketService, private httpService: InterceptedHttp) { this._keySize = 256; this._ivSize = 128; @@ -91,8 +92,8 @@ export class loginContentClass implements OnInit, OnDestroy { this.dataSettingService.loginIP = response.loginIPAddress; console.log('array' + this.previlageObj); if (response.isAuthenticated === true && response.Status === 'Active') { - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); this.router.navigate(['/MultiRoleScreenComponent'], { skipLocationChange: true }); } // } else { @@ -134,8 +135,8 @@ export class loginContentClass implements OnInit, OnDestroy { this.dataSettingService.loginIP = response.loginIPAddress; console.log('array' + this.previlageObj); if (response.isAuthenticated === true && response.Status === 'Active') { - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); this.router.navigate(['/MultiRoleScreenComponent'], { skipLocationChange: true }); } // } else { @@ -234,10 +235,15 @@ export class loginContentClass implements OnInit, OnDestroy { // this.password = CryptoJS.SHA256(this.password).toString(); // this.encryptedVar=SHA256(this.password).toString(enc.Hex); // this.password=this.encryptedVar.substr(0, 16); - this.loginservice + console.error("response"); + this.loginservice .authenticateUser(this.userID, this.encryptPassword, doLogOut) .subscribe( (response: any) => { + console.error("response",response); + let tkn = response.Jwttoken; + this.sessionstorage.setCookie('Jwttoken', tkn,1 ); + if ( response !== undefined && response !== null && @@ -246,10 +252,18 @@ export class loginContentClass implements OnInit, OnDestroy { ) { this.successCallback(response, this.userID, this.password); } + }, + (error: any) => this.errorCallback(error) - ); + + ); + + + + } + // login(doLogOut) { // this.loginservice @@ -280,6 +294,9 @@ export class loginContentClass implements OnInit, OnDestroy { .authenticateUser(this.userID, this.encryptPassword, doLogOut) .subscribe( (response: any) => { + console.log("response.Jwttoken",response) + let tkn = response.Jwttoken; + this.sessionstorage.setCookie('Jwttoken', tkn,1 ); if ( response !== undefined && response !== null && @@ -328,8 +345,8 @@ export class loginContentClass implements OnInit, OnDestroy { if (this.dataSettingService.current_serviceID === undefined) { alert('ServiceID not found. Some things may not work'); } - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); sessionStorage.setItem('authToken', response.key); this.router.navigate(['/MultiRoleScreenComponent'], { skipLocationChange: true }); // this.socketService.reInstantiate(); @@ -337,8 +354,8 @@ export class loginContentClass implements OnInit, OnDestroy { } if (response.isAuthenticated === true && response.Status === 'New') { sessionStorage.setItem('authToken', response.key); - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); this.router.navigate(['/setQuestions']); } // } else { diff --git a/src/app/multi-role-screen/multi-role-screen.component.ts b/src/app/multi-role-screen/multi-role-screen.component.ts index 8f767b9f..2d0ac254 100644 --- a/src/app/multi-role-screen/multi-role-screen.component.ts +++ b/src/app/multi-role-screen/multi-role-screen.component.ts @@ -40,6 +40,7 @@ import { AgentForceLogoutComponent } from '../agent-force-logout/agent-force-log import { HttpServices } from "../services/http-services/http_services.service"; import { ViewVersionDetailsComponent } from '../view-version-details/view-version-details.component'; import { SetLanguageComponent } from 'app/set-language.component'; +import { sessionStorageService } from 'app/services/sessionStorageService/session-storage.service'; @Component({ selector: 'app-multi-role-screen', @@ -72,7 +73,7 @@ export class MultiRoleScreenComponent implements OnInit { app_language: any; languageArray: any; - constructor(public dataSettingService: dataService, private _config: ConfigService, location: PlatformLocation, + constructor(public dataSettingService: dataService,private sessionstorage:sessionStorageService, private _config: ConfigService, location: PlatformLocation, public router: Router, private authService: AuthService, private _loginService: loginService, private Czentrix: CzentrixServices, private alertMessage: ConfirmationDialogsService, private sanitizer: DomSanitizer, private listnerService: ListnerService, private dialog: MdDialog, public HttpServices: HttpServices) { @@ -179,10 +180,10 @@ export class MultiRoleScreenComponent implements OnInit { // if (this.current_role.toLowerCase() === "supervisor") { this.Czentrix.userLogout().subscribe( (response) => { - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); sessionStorage.removeItem('apiman_key'); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("setLanguage"); this.dataSettingService.appLanguage="English"; this.authService.removeToken(); this.router.navigate(['']); @@ -190,10 +191,10 @@ export class MultiRoleScreenComponent implements OnInit { // this.socketService.logOut(); }, (err) => { - sessionStorage.removeItem('isOnCall'); - sessionStorage.removeItem('isEverwellCall'); + this.sessionstorage.removeItem('isOnCall'); + this.sessionstorage.removeItem('isEverwellCall'); sessionStorage.removeItem('apiman_key'); - sessionStorage.removeItem("setLanguage"); + this.sessionstorage.removeItem("setLanguage"); this.dataSettingService.appLanguage="English"; this.authService.removeToken(); this.router.navigate(['']); @@ -206,19 +207,19 @@ export class MultiRoleScreenComponent implements OnInit { // if (res.response.status.toUpperCase() !== 'FAIL') { // this.Czentrix.userLogout().subscribe( // (response) => { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem('apiman_key'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem('apiman_key'); + // this.sessionstorage.removeItem("setLanguage"); // this.dataSettingService.appLanguage="English"; // this.router.navigate(['']); // // this.socketService.logOut(); // }, // (err) => { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem('apiman_key'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem('apiman_key'); + // this.sessionstorage.removeItem("setLanguage"); // this.dataSettingService.appLanguage="English"; // this.router.navigate(['']); // // this.socketService.logOut(); @@ -242,28 +243,28 @@ export class MultiRoleScreenComponent implements OnInit { // this.Czentrix.agentLogout(this.dataSettingService.cZentrixAgentID, response).subscribe((res) => { // if( res !== undefined && res !== null) { // if (res.response !== undefined && res.response.status !== undefined && res.response.status.toUpperCase() !== 'FAIL') { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem("setLanguage"); // this.dataSettingService.appLanguage="English"; // this.router.navigate(['']); - // sessionStorage.removeItem('apiman_key'); + // this.sessionstorage.removeItem('apiman_key'); // this.authService.removeToken(); // } else { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem("setLanguage"); // this.dataSettingService.appLanguage="English"; // this.router.navigate(['']); - // sessionStorage.removeItem('apiman_key'); + // this.sessionstorage.removeItem('apiman_key'); // this.authService.removeToken(); // } // } // }, (err) => { - // sessionStorage.removeItem('isOnCall'); - // sessionStorage.removeItem('isEverwellCall'); - // sessionStorage.removeItem("setLanguage"); + // this.sessionstorage.removeItem('isOnCall'); + // this.sessionstorage.removeItem('isEverwellCall'); + // this.sessionstorage.removeItem("setLanguage"); // this.dataSettingService.appLanguage="English"; // this.router.navigate(['']); // this.authService.removeToken(); @@ -341,8 +342,8 @@ export class MultiRoleScreenComponent implements OnInit { } getLanguage() { - if (sessionStorage.getItem("setLanguage") != null) { - this.changeLanguage(sessionStorage.getItem("setLanguage")); + if (this.sessionstorage.getItem("setLanguage") != null) { + this.changeLanguage(this.sessionstorage.getItem("setLanguage")); } else { this.changeLanguage(this.app_language); } @@ -372,7 +373,7 @@ export class MultiRoleScreenComponent implements OnInit { } console.log("language is ", response); this.currentLanguageSet = response[language]; - sessionStorage.setItem("setLanguage", language); + this.sessionstorage.setItem("setLanguage", language); if (this.currentLanguageSet) { this.languageArray.forEach((item) => { if (item.languageName === language) { diff --git a/src/app/services/authGuardService/auth-guard.services.ts b/src/app/services/authGuardService/auth-guard.services.ts index 7005d9ed..f10d00fe 100644 --- a/src/app/services/authGuardService/auth-guard.services.ts +++ b/src/app/services/authGuardService/auth-guard.services.ts @@ -34,6 +34,7 @@ import { AuthService } from './../../services/authentication/auth.service'; import 'rxjs/add/operator/toPromise' import { SetLanguageComponent } from 'app/set-language.component'; import { HttpServices } from '../http-services/http_services.service'; +import { sessionStorageService } from '../sessionStorageService/session-storage.service'; @Injectable() export class AuthGuard implements CanActivate { _baseURL = this._config.getCommonBaseURL(); @@ -41,7 +42,7 @@ export class AuthGuard implements CanActivate { _deleteToken = this._baseURL + 'user/userLogout'; currentLanguageSet: any; constructor( - private router: Router, + private router: Router,private sessionstorage:sessionStorageService, private route: ActivatedRoute, public dataSettingService: dataService, private _http: InterceptedHttp , private _config: ConfigService, private authService: AuthService,public httpServices:HttpServices) { } @@ -60,7 +61,7 @@ export class AuthGuard implements CanActivate { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - const key = sessionStorage.getItem('isOnCall'); + const key = this.sessionstorage.getItem('isOnCall'); const authkey = sessionStorage.getItem('authToken'); // if (authkey) { diff --git a/src/app/services/config/config.service.ts b/src/app/services/config/config.service.ts index c70b1e16..a07565b3 100644 --- a/src/app/services/config/config.service.ts +++ b/src/app/services/config/config.service.ts @@ -29,24 +29,24 @@ import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; import * as config from 'assets/config.json'; -const commonIP = 'http://10.208.122.38:8080/'; -const IP1097 = 'http://10.208.122.38:8080/'; -const telephonyServerIP = 'http://10.208.122.99/'; -const adminIP = 'http://10.208.122.38:8080/'; +const commonIP = 'https://amritwprdev.piramalswasthya.org/'; +const IP1097 = 'https://amritwprdev.piramalswasthya.org/'; +const telephonyServerIP = 'http://192.168.45.55/'; +const adminIP = 'https://amritwprdev.piramalswasthya.org/'; @Injectable() export class ConfigService { // private _commonBaseURL: String = `${commonIP}commonapi-v1.0/`; - private _commonBaseURL: String = `http://10.208.122.38:8080/commonapi-v1.2/`; + private _commonBaseURL: String = `https://amritwprdev.piramalswasthya.org/commonapi-v3.0.0/`; // private _commonBaseURL: String=`http://localhost:8080/`; // private openCommonURL: String = `${commonIP}commonapi-v1.0/`; - private openCommonURL: String = `http://10.208.122.38:8080/commonapi-v1.2/`; - private _helpline1097BaseURL: String = `${IP1097}1097api-v1.0/`; + private openCommonURL: String = `https://amritwprdev.piramalswasthya.org/commonapi-v3.0.0/`; + private _helpline1097BaseURL: String = `${IP1097}1097api-v3.0.0/`; private _telephonyServerURL: String = `${telephonyServerIP}`; private _localeString = 'en-in'; - private adminBaseUrl = `${adminIP}adminapi-v1.0/`; - private _opencommonBaseURL: String = `${commonIP}commonapi-v1.2/`; + private adminBaseUrl = `${adminIP}adminapi-v3.0.0/`; + private _opencommonBaseURL: String = `${commonIP}commonapi-v3.0.0/`; // private _commonBaseURL: String = 'http://deviemr.piramalswasthya.org:8080/commonapi-v1.0/'; // private _helpline1097BaseURL: String = 'http://deviemr.piramalswasthya.org:8080/1097api-v1.0/'; @@ -56,9 +56,9 @@ export class ConfigService { // private adminBaseUrl = 'http://deviemr.piramalswasthya.org:8080/adminapi-v1.0/'; //for APIMAN - // private _commonBaseURL: String = "http://10.208.122.38:8080/apiman-gateway/IEMR/Common/1.0/"; - // private openCommonURL: String = "http://10.208.122.38:8080/apiman-gateway/IEMR/Common/open/"; - // private _helpline1097BaseURL: String = 'http://10.208.122.38:8080/apiman-gateway/IEMR/1097/1.0/'; + // private _commonBaseURL: String = "https://amritwprdev.piramalswasthya.org/apiman-gateway/IEMR/Common/1.0/"; + // private openCommonURL: String = "https://amritwprdev.piramalswasthya.org/apiman-gateway/IEMR/Common/open/"; + // private _helpline1097BaseURL: String = 'https://amritwprdev.piramalswasthya.org/apiman-gateway/IEMR/1097/1.0/'; // private _commonBaseURL: String = 'http://l-185000861.wipro.com:8080/commonapi-v1.0/'; // private _helpline1097BaseURL: String = 'http://l-185000861.wipro.com:8080/1097api-v1.0/'; // private _telephonyServerURL: String = 'http://10.208.122.99/'; diff --git a/src/app/services/czentrix/czentrix.service.ts b/src/app/services/czentrix/czentrix.service.ts index 6f3ba301..65e73582 100644 --- a/src/app/services/czentrix/czentrix.service.ts +++ b/src/app/services/czentrix/czentrix.service.ts @@ -30,6 +30,7 @@ import { ConfigService } from '../config/config.service'; import { dataService } from '../dataService/data.service'; import { AuthorizationWrapper } from './../../authorization.wrapper'; import { InterceptedHttp } from './../../http.interceptor' +import { sessionStorageService } from '../sessionStorageService/session-storage.service'; @Injectable() @@ -52,7 +53,7 @@ export class CzentrixServices { _agentLogOut = this.openCommonUrl + 'cti/doAgentLogout'; logoutUserUrl = this.openCommonUrl + "user/userLogout"; phone_num: number; - constructor(private http: AuthorizationWrapper, + constructor(private http: AuthorizationWrapper,private sessionstorage:sessionStorageService, private _http: Http, private httpInterceptor: InterceptedHttp, private _config: ConfigService, private _data: dataService, private normalHTTP: Http) { this.agent_id = this._data.cZentrixAgentID; @@ -87,10 +88,10 @@ export class CzentrixServices { } userLogout() { - // sessionStorage.clear(); - sessionStorage.removeItem("privilege_flag"); - sessionStorage.removeItem("session_id"); - sessionStorage.removeItem("callTransferred"); + // this.sessionstorage.clear(); + this.sessionstorage.removeItem("privilege_flag"); + this.sessionstorage.removeItem("session_id"); + this.sessionstorage.removeItem("callTransferred"); return this.httpInterceptor .post(this.logoutUserUrl, {}) .map(this.extractData) diff --git a/src/app/services/loginService/login.service.ts b/src/app/services/loginService/login.service.ts index d5a42640..da5a3c31 100644 --- a/src/app/services/loginService/login.service.ts +++ b/src/app/services/loginService/login.service.ts @@ -30,6 +30,7 @@ import 'rxjs/add/operator/map'; import { InterceptedHttp } from './../../http.interceptor'; import { AuthorizationWrapper } from './../../authorization.wrapper'; import { ActivatedRoute, Router, Params } from '@angular/router'; +import { HttpClient } from '@angular/common/http'; @Injectable() export class loginService { @@ -47,7 +48,8 @@ export class loginService { transactionId: any; constructor( private _http: InterceptedHttp, - private _config: ConfigService + private _config: ConfigService, + private http:HttpClient, ) { } @@ -57,9 +59,9 @@ export class loginService { .catch(this.handleError); } public authenticateUser(uname: any, pwd: any, doLogout): Observable { - return this._http.post(this._userAuthURL, { 'userName': uname, 'password': pwd, doLogout: doLogout }) - .map(this.extractData) - .catch(this.handleError); + return this._http.post(this._userAuthURL, { 'userName': uname, 'password': pwd,withCredentials: true, doLogout: doLogout }) + .map(this.extractData) + .catch(this.handleError); }; public userLogOutFromPreviousSession(uname: any){ @@ -95,6 +97,7 @@ export class loginService { private extractData(response: Response) { + console.error("responce-service",response) if (response.json().data) { return response.json().data; } else { @@ -112,6 +115,7 @@ export class loginService { private handleError(error: Response | any) { + console.error("handleError",error) return Observable.throw(error.json()); }; diff --git a/src/app/services/sessionStorageService/session-storage.service.ts b/src/app/services/sessionStorageService/session-storage.service.ts new file mode 100644 index 00000000..09551296 --- /dev/null +++ b/src/app/services/sessionStorageService/session-storage.service.ts @@ -0,0 +1,100 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ + + +import { Injectable } from '@angular/core'; +import { environment } from 'environments/environment'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/map'; +import * as CryptoJS from 'crypto-js'; + +@Injectable() +export class sessionStorageService { + + SECRET_KEY = environment.encKey; + constructor( + //private cryptoService: CryptoEncService, + ) {} + + + // safeToString(value: any): any { + // if (value === null || value === undefined) { + // return ''; + // } + // return value.toString(); + // } + + setItem(key: string, value: any): void { + + const ciphertext = CryptoJS.AES.encrypt(value, this.SECRET_KEY).toString(); + sessionStorage.setItem(key,ciphertext); + + + } + + getItem(key: string): any | null { + let text=sessionStorage.getItem(key) + if(text && text!==null){ + const bytes = CryptoJS.AES.decrypt(text, this.SECRET_KEY); + const originalText = bytes.toString(CryptoJS.enc.Utf8); + // return this.store.get(key, this.SECRET_KEY); + return originalText + } + } + + + + + + + + removeItem(key: string): void { + sessionStorage.removeItem(key); + } + + clear(): void { + sessionStorage.clear(); + } + + + setCookie(name:any, value:any, days:number) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = "; expires=" + date.toUTCString(); + } document.cookie = name + "=" + (value || "") + expires + "; path=/"; + } + getCookie(name:any) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); + } + return null; + } + + + } + \ No newline at end of file diff --git a/src/environments/enckey.ts b/src/environments/enckey.ts new file mode 100644 index 00000000..868fd282 --- /dev/null +++ b/src/environments/enckey.ts @@ -0,0 +1,4 @@ +export const keys = { + dev: '896Y7lbv0qFr1WgppH0NjSNRJZ9nDciBNeH6MA0F1MZDJb0SXhceLPw2kSpdObG1', + prod: '896Y7lbv0qFr1WgppH0NjSNRJZ9nDciBNeH6MA0F1MZDJb0SXhceLPw2kSpdObG1', +} \ No newline at end of file diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0d824a6d..d23ef949 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -20,8 +20,11 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ +import { keys } from "./enckey"; + export const environment = { production: true, - invalidCallType: 'Invalid' + invalidCallType: 'Invalid', + encKey: keys.prod, }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 9e2e9e13..760c4134 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -20,6 +20,8 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ +import { keys } from "./enckey"; + // The file contents for the current environment will overwrite these during build. // The build system defaults to the dev environment which uses `environment.ts`, but if you do @@ -28,5 +30,6 @@ export const environment = { production: false, - invalidCallType: 'Invalid' + invalidCallType: 'Invalid', + encKey: keys.dev, };