-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
volar
committed
Dec 15, 2023
1 parent
8f451d1
commit c3d5213
Showing
13 changed files
with
69 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,3 @@ | ||
import { fetchCurrentUser } from '@/services/api/coreDam/userApi' | ||
import { envConfig } from '@/services/EnvConfigService' | ||
import { computed, readonly, ref } from 'vue' | ||
import type { CurrentUserDto } from '@/types/coreDam/CurrentUser' | ||
import { ROLE_SUPER_ADMIN } from '@anzusystems/common-admin' | ||
import { useUserDisplayHelper } from '@/composables/system/userDisplayHelper' | ||
|
||
const currentUser = ref<CurrentUserDto | undefined>(undefined) | ||
const currentUserIsSuperAdmin = ref(false) | ||
const showDevFeature = ref(false) | ||
|
||
export function logoutUser() { | ||
window.location.pathname = '/logout' | ||
} | ||
|
||
export function updateCurrentUser() { | ||
return new Promise((resolve, reject) => { | ||
fetchCurrentUser() | ||
.then((res: CurrentUserDto) => { | ||
currentUser.value = res | ||
if (res.roles.includes(ROLE_SUPER_ADMIN)) currentUserIsSuperAdmin.value = true | ||
if (currentUserIsSuperAdmin.value || envConfig.appVersion === 'dev') showDevFeature.value = true | ||
|
||
resolve(currentUser) | ||
}) | ||
.catch((err) => { | ||
reject(err) | ||
}) | ||
}) | ||
} | ||
|
||
const { getUsername } = useUserDisplayHelper() | ||
const currentUserUsername = computed(() => getUsername(currentUser.value)) | ||
|
||
export function useCurrentUser() { | ||
return { | ||
currentUser: readonly(currentUser), | ||
currentUserIsSuperAdmin: readonly(currentUserIsSuperAdmin), | ||
currentUserUsername: readonly(currentUserUsername), | ||
showDevFeature, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.