Skip to content

Commit

Permalink
Merge pull request #2324 from CruGlobal/fix/refresh-token
Browse files Browse the repository at this point in the history
Added refresh tokens
  • Loading branch information
rossellemabunga authored Jan 15, 2024
2 parents 3a42496 + 6ac19a9 commit b434a53
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/auth/providers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const SIGN_IN_WITH_THE_KEY_MUTATION = gql`
input: { keyAccessToken: $accessToken, anonymousUid: $anonymousUid }
) {
token
refreshToken
}
}
`;
Expand All @@ -16,6 +17,7 @@ export const SIGN_IN_WITH_FACEBOOK_MUTATION = gql`
input: { fbAccessToken: $accessToken, anonymousUid: $anonymousUid }
) {
token
refreshToken
}
}
`;
Expand All @@ -24,6 +26,7 @@ export const SIGN_IN_WITH_GOOGLE_MUTATION = gql`
mutation SignInWithGoogle($idToken: String!, $anonymousUid: String) {
loginWithGoogle(input: { idToken: $idToken, anonymousUid: $anonymousUid }) {
token
refreshToken
}
}
`;
Expand Down
4 changes: 4 additions & 0 deletions src/auth/providers/useSignInWithFacebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
setAuthToken,
getAnonymousUid,
deleteAnonymousUid,
setMissionHubRefreshToken,
} from '../authStore';
import { AuthError } from '../constants';
import { rollbar } from '../../utils/rollbar.config';
Expand Down Expand Up @@ -69,6 +70,9 @@ export const useSignInWithFacebook = () => {

if (data?.loginWithFacebook?.token) {
await setAuthToken(data.loginWithFacebook.token);
await setMissionHubRefreshToken(
data.loginWithFacebook?.refreshToken || '',
);
await deleteAnonymousUid();
} else {
throw new Error('apiSignInWithFacebook did not return an access token');
Expand Down
4 changes: 4 additions & 0 deletions src/auth/providers/useSignInWithGoogle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
setAuthToken,
getAnonymousUid,
deleteAnonymousUid,
setMissionHubRefreshToken,
} from '../authStore';
import { AuthError } from '../constants';
import { rollbar } from '../../utils/rollbar.config';
Expand Down Expand Up @@ -90,6 +91,9 @@ export const useSignInWithGoogle = () => {

if (data?.loginWithGoogle?.token) {
await setAuthToken(data.loginWithGoogle.token);
await setMissionHubRefreshToken(
data.loginWithGoogle?.refreshToken || '',
);
await deleteAnonymousUid();
} else {
throw new Error('apiSignInWithGoogle did not return an access token');
Expand Down
4 changes: 4 additions & 0 deletions src/auth/providers/useSignInWithTheKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getTheKeyRefreshToken,
setTheKeyRefreshToken,
deleteAnonymousUid,
setMissionHubRefreshToken,
} from '../authStore';
import { AuthError } from '../constants';
import { rollbar } from '../../utils/rollbar.config';
Expand Down Expand Up @@ -193,6 +194,9 @@ export const useSignInWithTheKey = () => {

if (data?.loginWithTheKey?.token) {
await setAuthToken(data.loginWithTheKey.token);
await setMissionHubRefreshToken(
data.loginWithTheKey?.refreshToken || '',
);
await deleteAnonymousUid();
} else {
throw new Error('apiSignInWithTheKey did not return an access token');
Expand Down

0 comments on commit b434a53

Please sign in to comment.