Skip to content

Commit 542bcec

Browse files
committed
Fix the handleSignIn() error object
In order to know if we should show the error description when sign in errors occur, we were counting on the updateReason property being set on the returning object. This was true until my last change, where we always return a valid UserInfo (except in this one case). After my change, the updateReason property was getting blown away and because of that, the logic around when to show the error message could never be true.
1 parent b2ff2e7 commit 542bcec

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/scripts/clipperUI/clipper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ class ClipperClass extends ComponentBase<ClipperState, {}> {
576576
let handleSignInEvent = new Log.Event.PromiseEvent(Log.Event.Label.HandleSignInEvent);
577577

578578
this.setState({ userResult: { status: Status.InProgress } });
579-
type ErrorObject = { correlationId?: string, error: string, errorDescription: string };
579+
type ErrorObject = { updateReason: UpdateReason, correlationId?: string, error: string, errorDescription: string };
580580
Clipper.getExtensionCommunicator().callRemoteFunction(Constants.FunctionKeys.signInUser, { param: authType, callback: (data: UserInfo | ErrorObject) => {
581581
// For cleaner referencing
582582
let updatedUser = data as UserInfo;
@@ -598,7 +598,7 @@ class ClipperClass extends ComponentBase<ClipperState, {}> {
598598
handleSignInEvent.setFailureInfo({ error: error });
599599

600600
errorObject.errorDescription = error;
601-
this.state.setState({ userResult: { status: Status.Failed, data: updatedUser } });
601+
this.state.setState({ userResult: { status: Status.Failed, data: errorObject } });
602602

603603
Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthSignInFailed);
604604
}

src/scripts/extensions/extensionWorkerBase.ts

+5
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ export abstract class ExtensionWorkerBase<TTab, TTabIdentifier> {
511511
}).catch((errorObject) => {
512512
// Set the user info object to undefined as a result of an attempted sign in
513513
this.auth.user.set({ updateReason: UpdateReason.SignInAttempt });
514+
515+
// Right now we're adding the update reason to the errorObject as well so that it is preserved in the callback.
516+
// The right thing to do is revise the way we use callbacks in the communicator and instead use Promises so that
517+
// we are able to return distinct objects.
518+
errorObject.updateReason = UpdateReason.SignInAttempt;
514519
return Promise.reject(errorObject);
515520
});
516521
});

0 commit comments

Comments
 (0)