Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: try it logout #502

Merged
merged 7 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/services/actions/auth-action-creators.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IAction } from '../../../types/action';
import { Mode } from '../../../types/enums';
import { logOut } from '../graph-client/msal-service';
import { logOut, logOutPopUp } from '../graph-client/msal-service';
import { GET_AUTH_TOKEN_SUCCESS, GET_CONSENTED_SCOPES_SUCCESS, LOGOUT_SUCCESS } from '../redux-constants';

export function getAuthTokenSuccess(response: string): IAction {
Expand Down Expand Up @@ -28,6 +28,8 @@ export function signOut() {
const { graphExplorerMode } = getState();
if (graphExplorerMode === Mode.Complete) {
logOut();
} else {
logOutPopUp();
}
dispatch(signOutSuccess(''));
};
Expand Down
14 changes: 14 additions & 0 deletions src/app/services/graph-client/msal-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ export function logOut() {
msalApplication.logout();
}

export function logOutPopUp() {
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we ignoring Typescript here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods I am accessing are private and surprisingly accessible as long as you ignore typescript.

It's an allowed workaround until the team releases a logoutPopUp implementation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add this as a comment, so that we know to stop ignoring Typescript in the future.

msalApplication.clearCache();
// @ts-ignore
msalApplication.account = null;
// @ts-ignore
msalApplication.authorityInstance.resolveEndpointsAsync().then(authority => {
const urlNavigate = authority.EndSessionEndpoint
? authority.EndSessionEndpoint
: `${msalApplication.authority}oauth2/v2.0/logout`;
(msalApplication as any).openPopup(urlNavigate, 'msal', 400, 600);
});
}

/**
* Generates a new access token from passed in scopes
* @param {string[]} scopes passed to generate token
Expand Down
2 changes: 2 additions & 0 deletions src/app/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ class App extends Component<IAppProps, IAppState> {
<div className={layout}>
{graphExplorerMode === Mode.TryIt && headerMessaging(classes, query)}

{graphExplorerMode === Mode.TryIt && this.displayAuthenticationSection(minimised)}

{displayContent && <>
<div style={{ marginBottom: 8 }}>
<QueryRunner onSelectVerb={this.handleSelectVerb} />
Expand Down