Skip to content

Cannot logout from AWS Cognito #249

@adrfinance

Description

@adrfinance

Hello,
I am using a code that looks like:

logout(): void {
  console.log('🚪 Logging out...');
  localStorage.clear();
  this.resetCircuitBreaker();
  this.updateAuthState({
    isAuthenticated: false,
    user: null,
    isProcessing: false,
    error: null
  });

  // AWS Cognito logout + redirect to login page
  const clientId = '12312312';
  const currentUrl = window.location.href;

  const redirectUri = encodeURIComponent(
    currentUrl.includes('localhost:4200')
      ? 'http://localhost:4200'
      : 'https://website.ai'
  );

  // Use redirect_uri (not logout_uri) to show login page after logout
  const logoutUrl = `https://website.us-east-2.amazoncognito.com/logout?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`;

  console.log('🔗 Logout URL:', logoutUrl);
  
  // Redirect to logout (will show login page)
  window.location.href = logoutUrl;
}

it takes me to a login page of cognito, but when I signed in I am still signed in as another user, which means it didn't log me out in the first place. What am I doing wrong? How can I fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions