Coverity-CWE 922: Insecure Storage of Sensitive Information(localStorage write)
[osm/NG-UI.git] / src / app / layouts / header / HeaderComponent.ts
index 9392177..13e2129 100644 (file)
@@ -95,8 +95,8 @@ export class HeaderComponent implements OnInit {
 
     /** Lifecyle Hooks the trigger before component is instantiate @public */
     public ngOnInit(): void {
-        this.isAdmin = (localStorage.getItem('isAdmin') === 'true') ? true : false;
-        this.isSystemAdmin = localStorage.getItem('admin_show') === 'true' ? true : false;
+        this.isAdmin = (sessionStorage.getItem('isAdmin') === 'true') ? true : false;
+        this.isSystemAdmin = sessionStorage.getItem('admin_show') === 'true' ? true : false;
         this.selectedProject = this.authService.ProjectName;
         this.authService.ProjectName.subscribe((projectNameFinal: string): void => {
             this.getSelectedProject = projectNameFinal;
@@ -105,7 +105,7 @@ export class HeaderComponent implements OnInit {
         this.projectService.setHeaderProjects();
         this.projectList$ = this.projectService.projectList;
         this.PACKAGEVERSION = environment.packageVersion;
-        const getLocalStorageVersion: string = localStorage.getItem('osmVersion');
+        const getLocalStorageVersion: string = sessionStorage.getItem('osmVersion');
         if (getLocalStorageVersion === null) {
             this.showNewVersion();
         } else if (getLocalStorageVersion !== this.sharedService.osmVersion) {
@@ -126,7 +126,7 @@ export class HeaderComponent implements OnInit {
     /** Close Version and add in local storage  @public */
     public closeVersion(): void {
         this.toShowNewTag = false;
-        localStorage.setItem('osmVersion', this.sharedService.osmVersion);
+        sessionStorage.setItem('osmVersion', this.sharedService.osmVersion);
     }
 
     /** Implementation of model for UserSettings options.@public */
@@ -139,7 +139,7 @@ export class HeaderComponent implements OnInit {
     public changePassword(): void {
         // eslint-disable-next-line security/detect-non-literal-fs-filename
         const modalRef: NgbModalRef = this.modalService.open(AddEditUserComponent, { backdrop: 'static' });
-        modalRef.componentInstance.userID = localStorage.getItem('user_id');
+        modalRef.componentInstance.userID = sessionStorage.getItem('user_id');
         modalRef.componentInstance.userTitle = this.translateService.instant('PAGE.USERS.EDITCREDENTIALS');
         modalRef.componentInstance.userType = 'changePassword';
         modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {