Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adal redirects to login page when opening in new tab #147

Open
argelj289 opened this issue Mar 17, 2021 · 1 comment
Open

adal redirects to login page when opening in new tab #147

argelj289 opened this issue Mar 17, 2021 · 1 comment

Comments

@argelj289
Copy link

I am having trouble with the application that uses adal-angular4

when I open the app in the new tab,

It asks again for my login although I already logged in.

here is the code I saw in the AppComponent.ts of the app

import { AdalService } from 'adal-angular4';
....

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {

  private adalConfiguration = {
    tenant: environment.adal.tenant,
    clientId: environment.adal.clientId,
    redirectUri: environment.adal.redirectUri,
    postLogoutRedirectUri: environment.adal.postLogoutRedirectUri,
    endpoints: environment.adal.endpoints
  }

  constructor(private adal: AdalService) {
    this.adal.init(this.adalConfiguration);
  }

  ngOnInit() {
    this.adal.handleWindowCallback();
    if (!this.adal.userInfo.authenticated) {
      this.adal.login();
    }

    // Log the user information to the console
    console.log('username ' + this.adal.userInfo.userName);
    console.log('authenticated: ' + this.adal.userInfo.authenticated);
    console.log('name: ' + this.adal.userInfo.profile.name);
    console.log('token: ' + this.adal.userInfo.token);
    console.log(this.adal.userInfo.profile);
    sessionStorage.setItem('access_token', this.adal.userInfo.token);
  }

}

@mihaiovidiu
Copy link

Hi,
Had the same problem, just set cacheLocation: "localStorage".
I found the answer here: #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants