Skip to content

Amplify gen 2, amplify-authenticator "There is already a signed in user."

0

I've been following the Amplify Gen 2 tutorial here: https://docs.amplify.aws/angular/start/quickstart/

I'm using Amplify Gen 2 and have a simple Angular 17 standalone app. When locally I run npx ampx sandbox then ng serve my app, I am able to signup and signin/signout multiple times. However, as soon as I alter the app and it reloads, I am signed out and on trying to sign in am warned There is already a signed in user.

Enter image description here

I can access the user pool in AWS for my sandbox and sign the user out:

Enter image description here

.. however, this makes no difference. The only way I can get it working again is to delete the sandbox and regenerate it.

There's nothing much going on in app.component:

<amplify-authenticator>
  <ng-template
    amplifySlot="authenticated"
    let-user="user"
    let-signOut="signOut"
  >
  <h1>Hello {{user?.signInDetails?.loginId}}</h1>
    <button (click)="signOut()">Sign Out</button>
    <h2>Welcome, {{ user.username }}!</h2>
  </ng-template>
</amplify-authenticator>

Unsure if this is relevant, but in resource.ts the Amplify auth is configued as follows:

export const data = defineData({
  schema,
  authorizationModes: {
    defaultAuthorizationMode: 'userPool',
  },
});

Any ideas at all? Not getting much confidence in Amplify Gen 2 with such a basic blocker so early on...

asked 2 years ago1.5K views
1 Answer
1
Accepted Answer

Turns out I was missing the following line of code above the @Component in app.component.ts:

Amplify.configure(outputs);

This also has to be in the constructor:

constructor(public authenticator: AuthenticatorService) {
    Amplify.configure(outputs);
}
answered 2 years ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.