Skip to content

Commit

Permalink
Trigger onUserLoggedIn() event on OAuth login (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaye407 authored Jun 11, 2019
1 parent d5fea6f commit 9b049a5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/sdk/src/auth/internal/CoreStitchAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,14 @@ export default abstract class CoreStitchAuth<TStitchUser extends CoreStitchUser>
credential: StitchCredential
): Promise<TStitchUser> {
if (credential instanceof StitchAuthResponseCredential) {
return this.processLogin(credential, credential.authInfo, credential.asLink);
return this.processLogin(credential, credential.authInfo, credential.asLink).then(user => {
this.dispatchAuthEvent({
kind: AuthEventKind.UserLoggedIn,
loggedInUser: user
});

return user;
});
}

/*
Expand Down Expand Up @@ -875,7 +882,7 @@ export default abstract class CoreStitchAuth<TStitchUser extends CoreStitchUser>
// Dispatch a UserAdded event if this is the first time this user is
// Being added to the list of users on the device.
if (newUserAdded) {
this.onAuthEvent() // Tegacy event dispatch
this.onAuthEvent() // Legacy event dispatch

this.dispatchAuthEvent({
addedUser: this.currentUser,
Expand Down

0 comments on commit 9b049a5

Please sign in to comment.