Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

447
Vistas
Why is my AWS Congito user able to sign in, but "not authenticated" when using Auth.currentAuthenticatedUser()?

I have manually added an AWS Cognito user to my application's user pool via the AWS management console. The required user pool credentials have been confirmed for this user. I am setting up an auth guard to control access to the routes. Whenever I use the Auth.signIn() function, the promise resolves successfully, however, when calling Auth.currentAuthenticatedUser() after signing in, the promise within the canActivate() function returns an error message "not authenticated". I have read GitHub issues on cookieStorage causing issues with this, but do not have this configured.

sign-in.component.ts

signIn(username, password) {

    return new Promise(() => {
        Auth
            .signIn(username, password)
            .then(() => {
                this.router.navigate(['main/dashboard']); // navigates to main/dashboard as expected
            })
            .catch(err => {
                this.authenticationError = err.message;
            })
    });
}

auth.guard.ts

canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    return Auth
               .currentAuthenticatedUser()
               .then(() => { 
                   return true; 
               })
               .catch((err) => { 
                   this.router.navigate(['signin']);
                   console.log(err) // "not authenticated"
                   return false;
               });
}
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Users created via the AWS management console are not considered authenticated unless the status field for that user is CONFIRMED. The status field in my case was FORCE_CHANGE_PASSWORD. AWS expects that users created via the console change their password after the first sign in or verify their account using an email or mobile verification. In the case of my app, I did not want to use either email or mobile verification. To resolve this I used the following aws-cli command for that user.

aws cognito-idp admin-set-user-password --user-pool-id your_user_pool_id --username username --password password --permanent
over 4 years ago · Santiago Trujillo Denunciar

0

I was facing this issue also after signing up, but it turns out you also need to log the user in too after you verify email with the code.

For example:

  1. Auth.signUp
  2. Auth.confirmSignUp
  3. Auth.signIn

For more info https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda