|
|
@@ -6,41 +6,39 @@ import {
|
|
|
baseOrganizationState,
|
|
|
OrignalAccessState
|
|
|
} from "~/types/interfaces";
|
|
|
-import {useOrganizationProfileStore} from "~/store/profile/organization";
|
|
|
|
|
|
-import {MyProfile} from "~/models/Access/MyProfile";
|
|
|
-import {useRepo} from "pinia-orm";
|
|
|
import {computed, ref, Ref} from "@vue/reactivity";
|
|
|
import {useEach} from "#imports";
|
|
|
import {useAbility} from "@casl/vue";
|
|
|
+import {useOrganizationProfileStore} from "~/stores/organizationProfile";
|
|
|
|
|
|
export const useAccessProfileStore = defineStore('accessProfile', () => {
|
|
|
|
|
|
// State
|
|
|
- const bearer = ref(null)
|
|
|
- const id = ref(null)
|
|
|
- const switchId = ref(null)
|
|
|
- const name = ref(null)
|
|
|
- const givenName = ref(null)
|
|
|
- const gender = ref(null)
|
|
|
- const avatarId = ref(null)
|
|
|
- const activityYear = ref(null)
|
|
|
+ const bearer: Ref<string | null> = ref(null)
|
|
|
+ const id: Ref<number | null> = ref(null)
|
|
|
+ const switchId: Ref<number | null> = ref(null)
|
|
|
+ const name: Ref<string | null> = ref(null)
|
|
|
+ const givenName: Ref<string | null> = ref(null)
|
|
|
+ const gender: Ref<string | null> = ref(null)
|
|
|
+ const avatarId: Ref<number | null> = ref(null)
|
|
|
+ const activityYear: Ref<number | null> = ref(null)
|
|
|
const historical = ref([])
|
|
|
const roles: Ref<Array<string>> = ref([])
|
|
|
- const abilities = ref([])
|
|
|
- const isAdminAccess = ref(false)
|
|
|
- const isSuperAdminAccess = ref(false)
|
|
|
- const isAdmin = ref(false)
|
|
|
- const isAdministratifManager = ref(false)
|
|
|
- const isPedagogicManager = ref(false)
|
|
|
- const isFinancialManager = ref(false)
|
|
|
- const isCaMember = ref(false)
|
|
|
- const isStudent = ref(false)
|
|
|
- const isTeacher = ref(false)
|
|
|
- const isMember = ref(false)
|
|
|
- const isOther = ref(false)
|
|
|
- const isGuardian = ref(false)
|
|
|
- const isPayer = ref(false)
|
|
|
+ const abilities: Ref<Array<AbilitiesType>> = ref([])
|
|
|
+ const isAdminAccess: Ref<boolean | null> = ref(false)
|
|
|
+ const isSuperAdminAccess: Ref<boolean | null> = ref(false)
|
|
|
+ const isAdmin: Ref<boolean | null> = ref(false)
|
|
|
+ const isAdministratifManager: Ref<boolean | null> = ref(false)
|
|
|
+ const isPedagogicManager: Ref<boolean | null> = ref(false)
|
|
|
+ const isFinancialManager: Ref<boolean | null> = ref(false)
|
|
|
+ const isCaMember: Ref<boolean | null> = ref(false)
|
|
|
+ const isStudent: Ref<boolean | null> = ref(false)
|
|
|
+ const isTeacher: Ref<boolean | null> = ref(false)
|
|
|
+ const isMember: Ref<boolean | null> = ref(false)
|
|
|
+ const isOther: Ref<boolean | null> = ref(false)
|
|
|
+ const isGuardian: Ref<boolean | null> = ref(false)
|
|
|
+ const isPayer: Ref<boolean | null> = ref(false)
|
|
|
const multiAccesses: Ref<Array<baseOrganizationState>> = ref([])
|
|
|
const familyAccesses: Ref<Array<baseAccessState>> = ref([])
|
|
|
const originalAccess = ref(null)
|
|
|
@@ -122,8 +120,6 @@ export const useAccessProfileStore = defineStore('accessProfile', () => {
|
|
|
// Time to set Organization Profile
|
|
|
const organizationProfileStore = useOrganizationProfileStore()
|
|
|
organizationProfileStore.setProfile(profile.organization)
|
|
|
-
|
|
|
- useRepo(MyProfile).save(profile)
|
|
|
}
|
|
|
|
|
|
const refreshProfile = (profile: any) => {
|
|
|
@@ -202,8 +198,6 @@ export const useAccessProfileStore = defineStore('accessProfile', () => {
|
|
|
return hasProfile;
|
|
|
}
|
|
|
|
|
|
- const { can } = useAbility()
|
|
|
-
|
|
|
/**
|
|
|
* Est-ce que l'utilisateur possède l'habilité
|
|
|
*
|
|
|
@@ -214,6 +208,8 @@ export const useAccessProfileStore = defineStore('accessProfile', () => {
|
|
|
if(abilities === null)
|
|
|
return true;
|
|
|
|
|
|
+ const { can } = useAbility()
|
|
|
+
|
|
|
let hasAbility= false;
|
|
|
abilities.map((ability) => {
|
|
|
if (can(ability.action, ability.subject))
|