mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
fix google login
This commit is contained in:
@@ -46,7 +46,7 @@ export default defineNuxtConfig({
|
|||||||
NOAUTH_USER_EMAIL: process.env.NOAUTH_USER_EMAIL,
|
NOAUTH_USER_EMAIL: process.env.NOAUTH_USER_EMAIL,
|
||||||
NOAUTH_USER_NAME: process.env.NOAUTH_USER_NAME,
|
NOAUTH_USER_NAME: process.env.NOAUTH_USER_NAME,
|
||||||
public: {
|
public: {
|
||||||
PAYPAL_CLIENT_ID: ''
|
GOOGLE_AUTH_CLIENT_ID: process.env.GOOGLE_AUTH_CLIENT_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
|
|
||||||
definePageMeta({ layout: 'none' });
|
definePageMeta({ layout: 'none' });
|
||||||
|
|
||||||
const { GOOGLE_AUTH_CLIENT_ID } = useRuntimeConfig();
|
const config = useRuntimeConfig()
|
||||||
|
const isNoAuth = ref<boolean>(config.public.GOOGLE_AUTH_CLIENT_ID == undefined);
|
||||||
|
|
||||||
const isNoAuth = ref<boolean>(GOOGLE_AUTH_CLIENT_ID == undefined);
|
const useCodeClientWrapper = isNoAuth.value === false ?
|
||||||
|
useCodeClient :
|
||||||
const useCodeClientWrapper = isNoAuth.value === true ? useCodeClient : (...args: any) => {
|
(...args: any) => {
|
||||||
return { isReady: false, login: () => { } }
|
return { isReady: false, login: () => { } }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loginWithoutAuth() {
|
async function loginWithoutAuth() {
|
||||||
try {
|
try {
|
||||||
const result = await $fetch('/api/auth/no_auth');
|
const result = await $fetch('/api/auth/no_auth');
|
||||||
if (result.error) return alert('Error during login, please try again');
|
if (result.error) return alert('Error during login, please try again');
|
||||||
|
|
||||||
setToken(result.access_token);
|
setToken(result.access_token);
|
||||||
|
|
||||||
const user = await $fetch<any>('/api/user/me', { headers: { 'Authorization': 'Bearer ' + token.value } })
|
const user = await $fetch<any>('/api/user/me', { headers: { 'Authorization': 'Bearer ' + token.value } })
|
||||||
@@ -31,8 +32,8 @@ async function loginWithoutAuth() {
|
|||||||
router.push('/?just_logged=true');
|
router.push('/?just_logged=true');
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ex) {
|
} catch (ex: any) {
|
||||||
alert('Error during login.', ex.message);
|
alert('Error during login.' + ex.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user