Initial Version

This commit is contained in:
root
2025-12-21 10:09:54 -05:00
commit 4ae6befc7b
422 changed files with 47225 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
import { computed } from 'vue';
import { useUserStore } from '@KTXC/stores/userStore';
/**
* Composable for accessing user authentication, profile, and settings
* Provides a clean API for modules to access user data
*/
export function useUser() {
const store = useUserStore();
// =========================================================================
// Authentication
// =========================================================================
const isAuthenticated = computed(() => store.isAuthenticated);
const identifier = computed(() => store.identifier);
const identity = computed(() => store.identity);
const label = computed(() => store.label);
const roles = computed(() => store.roles);
const permissions = computed(() => store.permissions);
const hasPermission = (permission: string): boolean => {
return store.hasPermission(permission);
};
const hasAnyPermission = (perms: string[]): boolean => {
return store.hasAnyPermission(perms);
};
const hasAllPermissions = (perms: string[]): boolean => {
return store.hasAllPermissions(perms);
};
const hasRole = (role: string): boolean => {
return store.hasRole(role);
};
const logout = async (): Promise<void> => {
await store.logout();
};
// =========================================================================
// Profile
// =========================================================================
const profile = computed(() => store.profileFields);
const editableProfile = computed(() => store.editableProfileFields);
const managedProfile = computed(() => store.managedProfileFields);
const getProfile = (key: string): any => {
return store.getProfileField(key);
};
const setProfile = (key: string, value: any): boolean => {
return store.setProfileField(key, value);
};
const isProfileEditable = (key: string): boolean => {
return store.isProfileFieldEditable(key);
};
// =========================================================================
// Settings
// =========================================================================
const settings = computed(() => store.settings);
const getSetting = (key: string): any => {
return store.getSetting(key);
};
const setSetting = (key: string, value: any): void => {
store.setSetting(key, value);
};
return {
// Auth
isAuthenticated,
identifier,
identity,
label,
roles,
permissions,
hasPermission,
hasAnyPermission,
hasAllPermissions,
hasRole,
logout,
// Profile
profile,
editableProfile,
managedProfile,
getProfile,
setProfile,
isProfileEditable,
// Settings
settings,
getSetting,
setSetting,
};
}