Skip to content

Commit 792aa81

Browse files
authored
Merge pull request #297 from OneNoteDev/bug/o365-sign-in-errors
Bug/o365 sign in errors
2 parents 8f7caaa + 8e60663 commit 792aa81

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

src/scripts/clipperUI/clipper.tsx

+21-19
Original file line numberDiff line numberDiff line change
@@ -576,41 +576,43 @@ 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 };
580-
Clipper.getExtensionCommunicator().callRemoteFunction(Constants.FunctionKeys.signInUser, { param: authType, callback: (data: UserInfo | ErrorObject) => {
579+
580+
type ErrorObject = {
581+
updateReason: UpdateReason,
582+
correlationId?: string,
583+
error: string,
584+
errorDescription: string
585+
};
586+
587+
Clipper.getExtensionCommunicator().callRemoteFunction(Constants.FunctionKeys.signInUser, {
588+
param: authType, callback: (data: UserInfo | ErrorObject) => {
581589
// For cleaner referencing
590+
// TODO: This kind of thing should go away as we move the communicator to be Promise based.
582591
let updatedUser = data as UserInfo;
583592
let errorObject = data as ErrorObject;
584593

585-
// Unexpected errors
586-
let errorPrefix = AuthType[authType] + "; ";
587-
let error: string;
588-
if (!updatedUser) {
589-
error = errorPrefix + "The " + Constants.FunctionKeys.signInUser + " remote function incorrectly returned an undefined object";
590-
} else if (errorObject.error || errorObject.errorDescription) {
591-
// Something went wrong on the auth server
592-
error = errorPrefix + errorObject.error + ": " + errorObject.errorDescription;
593-
handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.CorrelationId, errorObject.correlationId);
594-
}
594+
let errorsFound = errorObject.error || errorObject.errorDescription;
595+
if (errorsFound) {
596+
errorObject.errorDescription = AuthType[authType] + ": " + errorObject.error + ": " + errorObject.errorDescription;
595597

596-
if (error) {
597-
handleSignInEvent.setStatus(Log.Status.Failed);
598-
handleSignInEvent.setFailureInfo({ error: error });
598+
this.state.setState({ userResult: { status: Status.Failed, data: errorObject } });
599599

600-
errorObject.errorDescription = error;
601-
this.state.setState({ userResult: { status: Status.Failed, data: updatedUser } });
600+
handleSignInEvent.setStatus(Log.Status.Failed);
601+
handleSignInEvent.setFailureInfo({ error: errorObject.errorDescription });
602+
handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.CorrelationId, errorObject.correlationId);
602603

603604
Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthSignInFailed);
604605
}
605606

606607
let userInfoReturned = updatedUser && !!updatedUser.user;
607608
if (userInfoReturned) {
608-
// Sign in succeeded
609609
Clipper.storeValue(ClipperStorageKeys.hasPatchPermissions, "true");
610610
Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthSignInCompleted);
611611
}
612+
612613
handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.UserInformationReturned, userInfoReturned);
613-
handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.SignInCancelled, !error && !userInfoReturned);
614+
handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.SignInCancelled, !errorsFound && !userInfoReturned);
615+
614616
Clipper.logger.logEvent(handleSignInEvent);
615617
}});
616618
}

src/scripts/clipperUI/panels/signInPanel.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ class SignInPanelClass extends ComponentBase<SignInPanelState, SignInPanelProps>
100100
debugInformation() {
101101
if (this.signInErrorDetected() && this.state.debugInformationShowing) {
102102
return <div id={Constants.Ids.signInErrorDebugInformation}>
103-
<span id={Constants.Ids.signInErrorDebugInformationDescription} style={Localization.getFontFamilyAsStyle(Localization.FontFamily.Light)}>
104-
{this.props.clipperState.userResult.data.errorDescription}
105-
</span>
106103
<div id={Constants.Ids.signInErrorDebugInformationContainer} style={Localization.getFontFamilyAsStyle(Localization.FontFamily.Light)}>
107104
<ul id={Constants.Ids.signInErrorDebugInformationList}>
108105
<li>{ClientType[this.props.clipperState.clientInfo.clipperType]}: {this.props.clipperState.clientInfo.clipperVersion}</li>

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
});

src/strings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"WebClipper.Error.ConflictingExtension": "Your PDF viewer or another extension might be blocking the OneNote Web Clipper. You could temporarily disable the following extension and try clipping again.",
4646
"WebClipper.Error.CannotClipPage": "Sorry, this type of page can\u0027t be clipped.",
4747
"WebClipper.Error.CookiesDisabled.Line1": "Cookies must be enabled in order for OneNote Web Clipper to work correctly.",
48-
"WebClipper.Error.CookiesDisabled.Line2": "Please allow third-party cookies in your browser or add the onenote.com domain as an exception.",
48+
"WebClipper.Error.CookiesDisabled.Line2": "Please allow third-party cookies in your browser or add the onenote.com and live.com domains as an exception.",
4949
"WebClipper.Error.CorruptedSection": "Your clip can\u0027t be saved here because the section is corrupt.",
5050
"WebClipper.Error.GenericError": "Something went wrong. Please try clipping the page again.",
5151
"WebClipper.Error.GenericExpiredTokenRefreshError": "Your login session has ended and we were unable to clip the page. Please sign in again.",

0 commit comments

Comments
 (0)