feat(fullstack): Set user roles per orga, scope notification to orga and role, add orga and role to JWT
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
UserApi,
|
||||
Configuration,
|
||||
type CreateUserDto,
|
||||
type UserDto
|
||||
} from '~/.api-client'
|
||||
import { UserApi, Configuration, type CreateUserDto, type UserDto } from '~/.api-client'
|
||||
import { cleanDoubleSlashes, withoutTrailingSlash } from 'ufo'
|
||||
|
||||
export function useUserApi() {
|
||||
@@ -15,25 +10,32 @@ export function useUserApi() {
|
||||
cleanDoubleSlashes(import.meta.client ? appBaseUrl + clientProxyBasePath : serverApiBaseUrl + serverApiBasePath)
|
||||
)
|
||||
|
||||
const userApiClient = new UserApi(
|
||||
new Configuration({ basePath, headers: { Authorization: jwt.value ? `Bearer ${jwt.value}` : '' } })
|
||||
// Track changing JWT of user who accepts the invitation
|
||||
const userApiClient = computed(
|
||||
() =>
|
||||
new UserApi(new Configuration({ basePath, headers: { Authorization: jwt.value ? `Bearer ${jwt.value}` : '' } }))
|
||||
)
|
||||
|
||||
async function createUser(createUserDto: CreateUserDto): Promise<UserDto> {
|
||||
return userApiClient.createUser({ createUserDto })
|
||||
return userApiClient.value.createUser({ createUserDto })
|
||||
}
|
||||
|
||||
async function getUserById(id: string): Promise<UserDto> {
|
||||
return userApiClient.getUserById({ id })
|
||||
return userApiClient.value.getUserById({ id })
|
||||
}
|
||||
|
||||
async function updateUser(id: string, userDto?: UserDto): Promise<UserDto> {
|
||||
return userApiClient.value.updateUser({ id, userDto })
|
||||
}
|
||||
|
||||
async function deleteUser(id: string): Promise<void> {
|
||||
return userApiClient.deleteUser({ id })
|
||||
return userApiClient.value.deleteUser({ id })
|
||||
}
|
||||
|
||||
return {
|
||||
createUser,
|
||||
getUserById,
|
||||
updateUser,
|
||||
deleteUser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user