0

I have a super admin who creates users. Super admin has an option to view as particular user (Just like facebook view as button) where he can access all the pages that the particular user can access.

Coming to implementation in angular, we are using JWT token stored in localstorage which should be included in headers for every API calls from client browser to server.

we want to open a private window in chrome browser for which we will store a separate token to access all the user related pages like a pop-up window or a incognito window in which we will open the url but with a different token.

can anyone please suggest any function where in some websites a child window opens and parent window cant be accessed till we close the child window.

public loginAsTenantAdmin(tenant) {
        this.tenantService.loginAsTenantAdmin(tenant.id).subscribe((response: any) => {
            var hello = window.open('http://localhost:4200')
            hello.sessionStorage.setItem('shadowUser', response.data.jwt);
        });
   }
 <a (click)="loginAsTenantAdmin(tenant)" class="btn m-btn--pill btn-sm">
    <i class="fa fa-user-lock" ngbTooltip="Login as Admin" style="color: teal">
    </i>
 </a>
kishan
  • 15
  • 6
  • Possible duplicate of [Communication between tabs or windows](https://stackoverflow.com/questions/28230845/communication-between-tabs-or-windows) – Lucho Jul 14 '19 at 20:03
  • no its not.. @lucho – kishan Jul 15 '19 at 08:26
  • Care to ellaborate or atleast brake down the question? – Lucho Jul 15 '19 at 12:21
  • edited please let me know if any doubts – kishan Jul 16 '19 at 10:22
  • using the below article [link] (https://medium.com/tekraze/popup-window-for-oauth-login-in-angular-2-applied-to-js-based-languages-also-fb811cd28b43) i'm able to open a pop-up window but i am not able clear localstorage and sessionstorage for that window as both are under same domain name localhost:4200 – kishan Jul 16 '19 at 12:33
  • @Lucho pls check – kishan Aug 15 '19 at 17:26
  • have a look at [this post](https://stackoverflow.com/questions/5523140/html5-local-storage-vs-session-storage), basically localStorage is suppose to persist it's data on the domain, however sessionStorage does not so are you sure it' still there when you open the new window? You have to close this post or refactor it with example code as your question is unclear now and people won't be reading long comment history. – Lucho Aug 16 '19 at 06:25

0 Answers0