Skip to content

Commit 8ff60cc

Browse files
fix(Auth): simplify logout call (#2258)
* remove revoke call * cleanup
1 parent 1da0cb2 commit 8ff60cc

4 files changed

Lines changed: 5 additions & 17 deletions

File tree

gatsby/onInitialClientRender.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export const onInitialClientRender = () => {
8383

8484
store.dispatch({ type: "setGapi", gapi })
8585
store.dispatch({ type: "gapiStatus", status: "initialized" })
86-
store.dispatch({ type: "setGoogle", google })
8786
store.dispatch({ type: "setTokenClient", tokenClient })
8887
})
8988
.catch(e => {

gatsby/wrapRootElement.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import {PartialDeep} from 'type-fest';
1818

1919
type State =
2020
{
21-
token?: {},
21+
token?: { },
2222
gapi?: PartialDeep<typeof gapi>,
23-
google?: any,
2423
tokenClient?: any,
2524
toast?: string,
2625
gapiStatus?: string
@@ -29,7 +28,6 @@ type State =
2928
type Action =
3029
| { type: 'setToken', token: {} | undefined }
3130
| { type: 'setGapi', gapi: PartialDeep<typeof gapi> | undefined }
32-
| { type: 'setGoogle', google: any }
3331
| { type: 'setTokenClient', tokenClient: any }
3432
| { type: 'setToast', toast: string | undefined }
3533
| { type: 'gapiStatus', status: string | undefined };
@@ -39,8 +37,6 @@ const reducer = (state: State = {}, action: Action) => {
3937
return { ...state, token: action.token }
4038
case "setGapi":
4139
return { ...state, gapi: action.gapi }
42-
case "setGoogle":
43-
return { ...state, google: action.google }
4440
case "setTokenClient":
4541
return { ...state, tokenClient: action.tokenClient }
4642
case "setToast":

src/components/Layout/useLogin.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const useLogin = (): Requestable<Successful, {}, InProgress, Failed> => {
2525
const gapi = useSelector((state: AppState) => state.gapi)
2626
const gapiStatus = useSelector((state: AppState) => state.gapiStatus)
2727
const tokenClient = useSelector((state: AppState) => state.tokenClient)
28-
const google = useSelector((state: AppState) => state.google)
2928
const dispatch = useDispatch()
3029
const userStatus = token ? UserStatus.SignedIn : UserStatus.SignedOut
3130

@@ -36,15 +35,10 @@ const useLogin = (): Requestable<Successful, {}, InProgress, Failed> => {
3635
}, [tokenClient])
3736

3837
const logout = useCallback(() => {
39-
const token = gapi?.client.getToken()
40-
if (token && google) {
41-
google.accounts.oauth2.revoke(token.access_token, () => {
42-
gapi?.client.setToken(null)
43-
dispatch({ type: "setToken", token: undefined })
44-
localStorage.removeItem("google_token")
45-
})
46-
}
47-
}, [gapi, google, dispatch])
38+
gapi?.client.setToken(null)
39+
dispatch({ type: "setToken", token: undefined })
40+
localStorage.removeItem("google_token")
41+
}, [gapi, dispatch])
4842

4943
useEffect(() => {
5044
if (gapiStatus === "cannot initialize") {

src/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ declare interface AppState {
2828
gapiStatus?: string
2929
measurementID: string
3030
tokenClient?: any
31-
google?: typeof google
3231
}

0 commit comments

Comments
 (0)