Skip to content

Commit

Permalink
fix: change username
Browse files Browse the repository at this point in the history
  • Loading branch information
BilelJegham committed Aug 13, 2023
1 parent 5df1258 commit f501f3d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/stores/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ export const useAuthStore = defineStore('auth', () => {
profile.value = data[0]
}

async function changeUsername(username: string) {
if (!userId.value || !profile.value) return

const { error } = await supabase
.from('profiles')
.update({
username,
})
.eq('user_id', userId.value)

if (error) throw error
profile.value.username = username
}

return {
profile,
session,
Expand All @@ -84,6 +98,7 @@ export const useAuthStore = defineStore('auth', () => {
updateConnection,
logout,
signInWithEmail,
changeUsername,
setProfile,
}
})

0 comments on commit f501f3d

Please sign in to comment.