(authType: AuthType)
| 574 | } |
| 575 | |
| 576 | private handleSignIn(authType: AuthType) { |
| 577 | Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthAttempted); |
| 578 | let handleSignInEvent = new Log.Event.PromiseEvent(Log.Event.Label.HandleSignInEvent); |
| 579 | |
| 580 | this.setState({ userResult: { status: Status.InProgress } }); |
| 581 | |
| 582 | type ErrorObject = { |
| 583 | updateReason: UpdateReason, |
| 584 | correlationId?: string, |
| 585 | error: string, |
| 586 | errorDescription: string |
| 587 | }; |
| 588 | |
| 589 | Clipper.getExtensionCommunicator().callRemoteFunction(Constants.FunctionKeys.signInUser, { |
| 590 | param: authType, callback: (data: UserInfo | ErrorObject) => { |
| 591 | // For cleaner referencing |
| 592 | // TODO: This kind of thing should go away as we move the communicator to be Promise based. |
| 593 | let updatedUser = data as UserInfo; |
| 594 | let errorObject = data as ErrorObject; |
| 595 | |
| 596 | let errorsFound = errorObject.error || errorObject.errorDescription; |
| 597 | if (errorsFound) { |
| 598 | errorObject.errorDescription = AuthType[authType] + ": " + errorObject.error + ": " + errorObject.errorDescription; |
| 599 | |
| 600 | this.state.setState({ userResult: { status: Status.Failed, data: errorObject } }); |
| 601 | |
| 602 | handleSignInEvent.setStatus(Log.Status.Failed); |
| 603 | handleSignInEvent.setFailureInfo({ error: errorObject.errorDescription }); |
| 604 | handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.CorrelationId, errorObject.correlationId); |
| 605 | |
| 606 | Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthSignInFailed); |
| 607 | } |
| 608 | |
| 609 | let userInfoReturned = updatedUser && !!updatedUser.user; |
| 610 | if (userInfoReturned) { |
| 611 | Clipper.storeValue(ClipperStorageKeys.hasPatchPermissions, "true"); |
| 612 | Clipper.logger.logUserFunnel(Log.Funnel.Label.AuthSignInCompleted); |
| 613 | } |
| 614 | |
| 615 | handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.UserInformationReturned, userInfoReturned); |
| 616 | handleSignInEvent.setCustomProperty(Log.PropertyName.Custom.SignInCancelled, !errorsFound && !userInfoReturned); |
| 617 | |
| 618 | Clipper.logger.logEvent(handleSignInEvent); |
| 619 | }}); |
| 620 | } |
| 621 | |
| 622 | private handleSignOut(authType: string): void { |
| 623 | this.state.setState(this.getSignOutState()); |
nothing calls this directly
no test coverage detected