mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-12 17:14:18 -04:00
Send code verifier to backend
This commit is contained in:
@@ -2,16 +2,17 @@ import {APIHandler} from './helpers/endpoint'
|
||||
import {GOOGLE_CLIENT_ID} from "common/constants";
|
||||
|
||||
export const authGoogle: APIHandler<'auth-google'> = async (
|
||||
{code},
|
||||
{code, codeVerifier},
|
||||
_auth
|
||||
) => {
|
||||
console.log('Google Auth Code:', code)
|
||||
if (!code) return {success: false, result: {}}
|
||||
console.log('Google Auth Codes:', code, codeVerifier)
|
||||
if (!code || !codeVerifier) return {success: false, result: {}}
|
||||
|
||||
const body = {
|
||||
client_id: GOOGLE_CLIENT_ID,
|
||||
client_secret: process.env.GOOGLE_CLIENT_SECRET!,
|
||||
code: code as string,
|
||||
code_verifier: codeVerifier as string,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: 'https://www.compassmeet.com/auth/callback',
|
||||
};
|
||||
|
||||
@@ -740,6 +740,7 @@ export const API = (_apiTypeCheck = {
|
||||
returns: {} as any,
|
||||
props: z.object({
|
||||
code: z.string(),
|
||||
codeVerifier: z.string(),
|
||||
}),
|
||||
summary: 'Google Auth',
|
||||
tag: 'Authentication',
|
||||
|
||||
@@ -81,7 +81,13 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {result} = await unauthedApi('auth-google', {code})
|
||||
const codeVerifier = localStorage.getItem('pkce_verifier');
|
||||
if (!codeVerifier) {
|
||||
console.error('No code verifier found in localStorage');
|
||||
return;
|
||||
}
|
||||
|
||||
const {result} = await unauthedApi('auth-google', {code, codeVerifier})
|
||||
console.log('/auth-google result', result);
|
||||
// google sign in
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user