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

Added refresh tokens #2324

Merged
merged 5 commits into from
Jan 15, 2024
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
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
Loading