Skip to content
Snippets Groups Projects
Unverified Commit 8f26985f authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

Avoid race between logging out and refreshing page (#10376)

parent 88396b67
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ export const loginGoogle = createThunkAction(LOGIN_GOOGLE, function(
await dispatch(refreshCurrentUser());
dispatch(push(redirectUrl || "/"));
} catch (error) {
clearGoogleAuthCredentials();
await clearGoogleAuthCredentials();
// If we see a 428 ("Precondition Required") that means we need to show the "No Metabase account exists for this Google Account" page
if (error.status === 428) {
dispatch(push("/auth/google_no_mb_account"));
......@@ -81,12 +81,12 @@ export const loginGoogle = createThunkAction(LOGIN_GOOGLE, function(
// logout
export const LOGOUT = "metabase/auth/LOGOUT";
export const logout = createThunkAction(LOGOUT, function() {
return function(dispatch, getState) {
return async function(dispatch, getState) {
// actively delete the session and remove the cookie
SessionApi.delete();
await SessionApi.delete();
// clear Google auth credentials if any are present
clearGoogleAuthCredentials();
await clearGoogleAuthCredentials();
MetabaseAnalytics.trackEvent("Auth", "Logout");
......
/*global gapi*/
/// clear out Google Auth credentials in browser if present
export function clearGoogleAuthCredentials() {
export async function clearGoogleAuthCredentials() {
const googleAuth =
typeof gapi !== "undefined" && gapi && gapi.auth2
? gapi.auth2.getAuthInstance()
......@@ -11,9 +11,7 @@ export function clearGoogleAuthCredentials() {
}
try {
googleAuth.signOut().then(function() {
console.log("Cleared Google Auth credentials.");
});
await googleAuth.signOut();
} catch (error) {
console.error("Problem clearing Google Auth credentials", error);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment