feat(fullstack): Set user roles per orga, scope notification to orga and role, add orga and role to JWT
This commit is contained in:
@@ -91,12 +91,33 @@ export const useOrganizationStore = defineStore('Organization', () => {
|
||||
try {
|
||||
await organizationApi.acceptInvitation(invitationId)
|
||||
await navigateTo('/')
|
||||
await syncUserRoleToBackend()
|
||||
} catch (e) {
|
||||
toast.add({ title: 'Error accepting invitation', color: 'error' })
|
||||
console.error('Error accepting invitation:', e)
|
||||
}
|
||||
}
|
||||
|
||||
async function syncUserRoleToBackend() {
|
||||
try {
|
||||
const { updateUser } = useUser()
|
||||
const { user } = useAuth()
|
||||
|
||||
if (!user.value?.id) {
|
||||
console.warn('No user ID available for role sync')
|
||||
return
|
||||
}
|
||||
|
||||
// Call updateUser without userDto to trigger JWT-based sync
|
||||
await updateUser(user.value.id)
|
||||
|
||||
console.log('Successfully synced user role to backend from JWT')
|
||||
} catch (error) {
|
||||
console.error('Failed to sync user role to backend from JWT:', error)
|
||||
// Don't throw - role sync failure shouldn't prevent invitation acceptance
|
||||
}
|
||||
}
|
||||
|
||||
async function cancelSentInvitation(invitationId: string) {
|
||||
try {
|
||||
await organizationApi.cancelSentInvitation(invitationId)
|
||||
|
||||
Reference in New Issue
Block a user