fix: refactor auth register to use pinia, clean up MapView obsolete telemetry call
This commit is contained in:
@ -51,6 +51,33 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function register(email: string, pass: string, fullName: string) {
|
||||
console.log('Realizando signUp en Supabase...')
|
||||
const { data, error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password: pass,
|
||||
options: {
|
||||
data: {
|
||||
full_name: fullName,
|
||||
role: 'PASSENGER'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (error) throw new Error(error.message)
|
||||
|
||||
// Supabase retorna sesión inmediata si auto-confirm está activado.
|
||||
if (data.session && data.user) {
|
||||
userSession.value = data.session
|
||||
userProfile.value = {
|
||||
id: data.user.id,
|
||||
email: data.user.email,
|
||||
full_name: data.user.user_metadata?.full_name || data.user.email,
|
||||
role: data.user.user_metadata?.role || 'PASSENGER'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
// Limpiar estado de Pinia inmediatamente
|
||||
userSession.value = null
|
||||
@ -84,6 +111,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
isPromoter,
|
||||
isPassenger,
|
||||
login,
|
||||
register,
|
||||
logout
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user