AWS Coginto Login screen for SignedIn user and for guest user hide loginscreen

Discussão em 'Angular' iniciado por Lovitha, Maio 14, 2025.

  1. Lovitha

    Lovitha Guest

    I'm using AWS coginito for login .For silent login i'm calling prompt=none url.Its working fine.Actally why we use this is we have other sites also there also we can sign In to coginto when we signed in that sit it should not show login screen when redirect to our site.What my issue is now we have a certain feature on one button click from other site direct get landed to our application as guest without aws login screen this makes the issue that when prompt-none url runs it will defintly redirect to login page. how can we avoid this.


    async ngOnInit() {
    const isCode = window.location.href.includes('?code');
    this.isCallback = isCode;
    if (!isCallbackUrl) {


    this.auth.trySilentLogin();



    } else {
    const code = this.getCodeFromUrl();
    if (code) {
    const tokens = await this.auth.exchangeCodeForTokens(code);
    window.history.replaceState({}, document.title, window.location.pathname);

    const idTokensPayload = this.parseJwt(tokens.id_token);
    console.log('Decoded userattributes', idTokensPayload);

    this.id = Number(idTokensPayload['custom:user_id']);



    }


    }


    }

    trySilentLogin(){
    const silentLogin=`${this.domain}/oauth2/authorize?` +
    `response_type=code&client_id=${this.clientId}&` +
    `redirect_uri=${encodeURIComponent(this.redirectUri)}&`+
    `scope=${this.authscope}&prompt=none`;
    window.location.href=silentLogin;
    }

    I also tried with amplify and custom login screen


    async ngOnInit() {

    const tokens:any = await fetchAuthSession();
    if( tokens.tokens?.accessToken){
    const idTokensPayload=tokens.tokens['idToken']
    this.id = Number(idTokensPayload.payload['custom:user_id']);


    this.isAuthenticated = true;


    }
    else{
    this.isAuthenticated = false;

    }

    }

    In this when redierect from other site to my site as logged in ittoken is undefined so whats the solution for this.Is any way to add auser as guest when redirect from other site.

    Continue reading...

Compartilhe esta Página