@drax/identity-vue 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.29.0",
6
+ "version": "0.30.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -24,12 +24,12 @@
24
24
  "format": "prettier --write src/"
25
25
  },
26
26
  "dependencies": {
27
- "@drax/common-front": "^0.29.0",
28
- "@drax/common-vue": "^0.29.0",
29
- "@drax/crud-front": "^0.29.0",
30
- "@drax/crud-share": "^0.29.0",
31
- "@drax/crud-vue": "^0.29.0",
32
- "@drax/identity-share": "^0.29.0"
27
+ "@drax/common-front": "^0.30.0",
28
+ "@drax/common-vue": "^0.30.0",
29
+ "@drax/crud-front": "^0.30.0",
30
+ "@drax/crud-share": "^0.30.0",
31
+ "@drax/crud-vue": "^0.30.0",
32
+ "@drax/identity-share": "^0.30.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "pinia": "^2.2.2",
@@ -66,5 +66,5 @@
66
66
  "vue-tsc": "^2.1.6",
67
67
  "vuetify": "^3.7.1"
68
68
  },
69
- "gitHead": "0a3f69beb23eb8768ebe7a3d41d61d4a6d40b104"
69
+ "gitHead": "f7f06578327be29f20dcb7e2c8a2eac9e9145cab"
70
70
  }
@@ -8,6 +8,7 @@ defineProps({
8
8
  errorMessages: {type: String as PropType<string | string[] | undefined>,},
9
9
  clearable: {type: Boolean, default: false},
10
10
  readonly: {type: Boolean, default: false},
11
+ hideDetails: {type: Boolean, default: false},
11
12
  itemTitle: {type: String, default: "name"},
12
13
  itemValue: {type: String, default: "_id"},
13
14
  rules: {type: Array as PropType<any[]>, default: () => []},
@@ -40,6 +41,8 @@ onMounted(async () => {
40
41
  :clearable="clearable"
41
42
  :rules="rules"
42
43
  :readonly="readonly"
44
+ :hide-details="hideDetails"
45
+ :density="density"
43
46
  ></v-select>
44
47
  </template>
45
48
 
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import {ref} from "vue"
3
+ import TenantCombobox from "../../combobox/TenantCombobox.vue";
4
+ import {useAuth} from "../../composables/useAuth"
5
+ import {useAuthStore} from "../../stores/auth/AuthStore"
6
+ import {useI18n} from "vue-i18n"
7
+
8
+ const authStore = useAuthStore()
9
+ const {switchTenant, hasPermission} = useAuth()
10
+
11
+ const {t} = useI18n()
12
+ const tenant = ref();
13
+
14
+ async function changeTenant() {
15
+ await switchTenant(tenant.value)
16
+ window.location.reload();
17
+ }
18
+
19
+ </script>
20
+
21
+ <template>
22
+ <v-toolbar v-if="hasPermission('user:switchTenant')">
23
+ <v-toolbar-title>
24
+ <b>{{t('tenant.current')}}:</b> {{authStore.authUser?.tenant ? authStore.authUser?.tenant?.name : '-'}}
25
+ </v-toolbar-title>
26
+ <v-spacer></v-spacer>
27
+ <tenant-combobox v-model="tenant" hide-details variant="outlined" density="compact" clearable ></tenant-combobox>
28
+ <v-btn size="small" @click="changeTenant">{{t('action.change')}}</v-btn>
29
+ </v-toolbar>
30
+
31
+ </template>
32
+
33
+ <style scoped>
34
+
35
+ </style>
@@ -17,6 +17,14 @@ export function useAuth() {
17
17
  authStore.setAuthUser(authUser)
18
18
  }
19
19
 
20
+
21
+ const switchTenant = async (tenantId: string) => {
22
+ const {accessToken} = await authSystem.switchTenant(tenantId)
23
+ authStore.setAccessToken(accessToken)
24
+ const authUser = await authSystem.me()
25
+ authStore.setAuthUser(authUser)
26
+ }
27
+
20
28
  const loginWithToken = async (token: string) => {
21
29
  authStore.setAccessToken(token)
22
30
  if(tokenIsValid()){
@@ -76,10 +84,9 @@ export function useAuth() {
76
84
  }
77
85
 
78
86
  function isAuthenticated() {
79
- if (tokenIsValid()) {
87
+ if (authStore.authUser && tokenIsValid()) {
80
88
  return true
81
89
  } else {
82
- clearAuth()
83
90
  return false
84
91
  }
85
92
 
@@ -91,7 +98,7 @@ export function useAuth() {
91
98
  isAuthenticated, fetchAuthUser,
92
99
  changeOwnPassword, changeAvatar,
93
100
  recoveryPasswordRequest, recoveryPasswordComplete,
94
- register
101
+ register, switchTenant
95
102
  }
96
103
 
97
104
  }
@@ -67,7 +67,7 @@ const {
67
67
  prepend-inner-icon="mdi-card-account-details"
68
68
  :variant="variant"
69
69
  :error-messages="$ta(store.inputErrors?.name)"
70
- :rules="[v => !!v || 'validation.required']"
70
+ :rules="[v => !!v || t('validation.required')]"
71
71
  density="default"
72
72
  :readonly="readonly"
73
73
  :clearable="false"
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import IdentityProfileAvatar from "./components/IdentityProfileAvatar/IdentityPr
3
3
  import IdentityProfileDrawer from "./components/IdentityProfileDrawer/IdentityProfileDrawer.vue";
4
4
  import IdentityProfileView from "./components/IdentityProfileView/IdentityProfileView.vue";
5
5
  import IdentityProfileAvatarEdit from "./components/IdentityProfileAvatarEdit/IdentityProfileAvatarEdit.vue";
6
+ import SwitchTenant from "./components/SwitchTenant/SwitchTenant.vue";
6
7
 
7
8
  import UserCrudPage from "./pages/crud/UserCrudPage.vue";
8
9
  import UserForm from "./cruds/user-crud/UserForm.vue";
@@ -56,6 +57,7 @@ export {
56
57
  IdentityProfileView,
57
58
  IdentityProfileDrawer,
58
59
  IdentityProfileAvatarEdit,
60
+ SwitchTenant,
59
61
 
60
62
  //Pages
61
63
  LoginPage,