fix: Google Sign-In - Firebase Admin credentials via env var + mobile redirect flow
This commit is contained in:
@ -1,10 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import LoginForm from '@/components/auth/LoginForm.vue'
|
||||
import RegisterForm from '@/components/auth/RegisterForm.vue'
|
||||
import { getGoogleRedirectResult } from '@/firebaseConfig'
|
||||
import { authService } from '@/services/authService'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const isLogin = ref(true)
|
||||
const toggleAuth = () => { isLogin.value = !isLogin.value }
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// Handle redirect result from Google Sign-In on mobile
|
||||
// (signInWithRedirect reloads the page; we catch the result here on load)
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const result = await getGoogleRedirectResult()
|
||||
if (result) {
|
||||
const response = await authService.googleLogin(result.token)
|
||||
authStore.login(response.access_token, response.role, response.full_name)
|
||||
const role = response.role.toUpperCase()
|
||||
if (role === 'ADMIN') router.push('/admin')
|
||||
else if (role === 'DRIVER') router.push('/driver')
|
||||
else if (role === 'PROMOTER') router.push('/promoter')
|
||||
else router.push('/map')
|
||||
}
|
||||
} catch (e) {
|
||||
// No redirect result pending, or error — ignore silently
|
||||
console.warn('Google redirect result:', e)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user