@simitgroup/simpleapp-generator 1.6.6-q-alpha → 1.6.6-r-alpha

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.
Files changed (66) hide show
  1. package/ReleaseNote.md +3 -0
  2. package/dist/buildinschemas/index.d.ts +1 -0
  3. package/dist/buildinschemas/index.d.ts.map +1 -1
  4. package/dist/buildinschemas/index.js +3 -1
  5. package/dist/buildinschemas/index.js.map +1 -1
  6. package/dist/buildinschemas/message.d.ts +3 -0
  7. package/dist/buildinschemas/message.d.ts.map +1 -0
  8. package/dist/buildinschemas/message.js +34 -0
  9. package/dist/buildinschemas/message.js.map +1 -0
  10. package/dist/buildinschemas/webhook.d.ts.map +1 -1
  11. package/dist/buildinschemas/webhook.js +124 -53
  12. package/dist/buildinschemas/webhook.js.map +1 -1
  13. package/dist/buildinschemas/webhookhistory.d.ts +3 -0
  14. package/dist/buildinschemas/webhookhistory.d.ts.map +1 -0
  15. package/dist/buildinschemas/webhookhistory.js +44 -0
  16. package/dist/buildinschemas/webhookhistory.js.map +1 -0
  17. package/dist/buildinschemas/webhooklog.d.ts +3 -0
  18. package/dist/buildinschemas/webhooklog.d.ts.map +1 -0
  19. package/dist/buildinschemas/webhooklog.js +77 -0
  20. package/dist/buildinschemas/webhooklog.js.map +1 -0
  21. package/dist/createproject.js +138 -0
  22. package/dist/createproject.js.map +1 -0
  23. package/dist/framework.js +3 -3
  24. package/dist/framework.js.map +1 -1
  25. package/dist/generate-allow-changebackend.js +305 -0
  26. package/dist/generate-allow-changebackend.js.map +1 -0
  27. package/dist/generate.js +2 -2
  28. package/dist/generate.js.map +1 -1
  29. package/dist/index2.js +118 -0
  30. package/dist/index2.js.map +1 -0
  31. package/dist/installdependency.js +20 -0
  32. package/dist/installdependency.js.map +1 -0
  33. package/dist/installnest.js +2 -0
  34. package/dist/installnest.js.map +1 -0
  35. package/dist/installnuxt.js +2 -0
  36. package/dist/installnuxt.js.map +1 -0
  37. package/dist/processors/groupsbuilder.js +2 -0
  38. package/dist/processors/groupsbuilder.js.map +1 -0
  39. package/dist/schematype/baseschema.js +25 -0
  40. package/dist/schematype/baseschema.js.map +1 -0
  41. package/dist/schematype/default.js +2 -0
  42. package/dist/schematype/default.js.map +1 -0
  43. package/dist/schematype/index.js +12 -0
  44. package/dist/schematype/index.js.map +1 -0
  45. package/dist/schematype/primarymasterdata.js +38 -0
  46. package/dist/schematype/primarymasterdata.js.map +1 -0
  47. package/dist/schematype/simple.js +24 -0
  48. package/dist/schematype/simple.js.map +1 -0
  49. package/dist/schematype/simplemasterdata.js +31 -0
  50. package/dist/schematype/simplemasterdata.js.map +1 -0
  51. package/dist/schematype/transaction.js +74 -0
  52. package/dist/schematype/transaction.js.map +1 -0
  53. package/package.json +1 -1
  54. package/src/buildinschemas/index.ts +1 -0
  55. package/src/buildinschemas/webhook.ts +126 -55
  56. package/src/buildinschemas/webhooklog.ts +75 -0
  57. package/src/framework.ts +4 -4
  58. package/src/generate.ts +2 -2
  59. package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +4 -2
  60. package/templates/nest/src/simpleapp/generate/commons/runwebhook.service.ts.eta +143 -168
  61. package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +22 -13
  62. package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +22 -16
  63. package/templates/nest/src/simpleapp/webhooks/branch.ts._eta +37 -0
  64. package/templates/nest/src/simpleapp/webhooks/index.ts._eta +21 -0
  65. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +341 -316
  66. /package/templates/nest/src/simpleapp/generate/processors/{webhook.processor.ts.eta → webhook.processor.ts.etaxxxx} +0 -0
@@ -5,336 +5,361 @@
5
5
  * Author: Ks Tan
6
6
  */
7
7
  import { defineNuxtPlugin } from "#app";
8
- import { PROFILEApi } from "../simpleapp/generate/openapi";
9
- import { UserProfile } from "~/types";
10
- import axios, { Axios, AxiosError, AxiosResponse } from "axios";
11
- import _ from "lodash";
8
+ import {PROFILEApi} from '../simpleapp/generate/openapi'
9
+ import {UserProfile} from '~/types'
10
+ import axios, { Axios, AxiosError, AxiosResponse } from 'axios'
11
+ import _ from 'lodash'
12
12
  import { group } from "console";
13
13
  import { HIGH_PRIVILEGE_ROLES } from "~/data/constant";
14
14
 
15
- export default defineNuxtPlugin(async (nuxtApp) => {
16
- const useUserStore = defineStore("userstore", {
17
- state: () => ({
18
- _id: ref(""),
19
- sessionId: ref(""),
20
- tenantId: ref(0),
21
- orgId: ref(0),
22
- branchId: ref(0),
23
- branchRecordId: ref(""),
24
- branchCode: ref(""),
25
- branchName: ref(""),
26
- orgRecordId: ref(""),
27
- orgCode: ref(""),
28
- orgName: ref(""),
29
- timeZone: ref(""),
30
- currency: ref(""),
31
- country: ref(""),
32
- offsetMinute: ref(0),
33
- uid: ref(""),
34
- email: ref(""),
35
- fullName: ref(""),
36
- roles: ref<string[]>([]),
37
- groups: ref<string[]>([]),
38
- currentGroup: ref(""),
39
- branches: ref([]),
40
- invites: ref([]),
41
- time: ref(""),
42
- moreProps: ref(),
43
- package: ref(),
44
- appintegration: ref({
45
- einvoice: false,
46
- simbiz6: false,
47
- }),
48
- }),
49
15
 
50
- actions: {
51
- async loadRemoteUserInfo() {
52
- // console.log('loadRemoteUserInfo')
53
-
54
- const { $axios, $appPluginsStore, $customFieldStore } = useNuxtApp();
55
- const route = useRoute();
56
- let xorg = this.getCurrentXorg();
57
-
58
- let apiurl = "";
59
- if (xorg === undefined) {
60
- apiurl = `${useRuntimeConfig().public.appUrl}/api`;
61
- } else {
62
- apiurl = `${useRuntimeConfig().public.appUrl}/api/${xorg}`;
63
- }
64
-
65
- await $appPluginsStore.loadInstalledPlugins();
66
- await $customFieldStore.fetchList();
16
+ export default defineNuxtPlugin( async(nuxtApp) => {
17
+ const useUserStore = defineStore('userstore', {
18
+ state: ()=>({
19
+ _id: ref(''),
20
+ sessionId:ref(''),
21
+ tenantId:ref(0),
22
+ orgId:ref(0),
23
+ branchId:ref(0),
24
+ branchRecordId:ref(''),
25
+ branchCode:ref(''),
26
+ branchName:ref(''),
27
+ orgRecordId:ref(''),
28
+ orgCode:ref(''),
29
+ orgName:ref(''),
30
+ timeZone:ref(''),
31
+ currency:ref(''),
32
+ country: ref(''),
33
+ offsetMinute: ref(0),
34
+ uid: ref(''),
35
+ email: ref(''),
36
+ fullName: ref(''),
37
+ roles:ref<string[]>([]),
38
+ groups:ref<string[]>([]),
39
+ currentGroup:ref(''),
40
+ branches:ref([]),
41
+ invites : ref([]),
42
+ time:ref(''),
43
+ moreProps:ref(),
44
+ package: ref(),
45
+ appintegration: ref({
46
+ einvoice: false,
47
+ simbiz6: false
48
+ })
49
+ }),
50
+
51
+ actions:{
52
+ async loadRemoteUserInfo(){
53
+ // console.log('loadRemoteUserInfo')
54
+
55
+ const { $axios, $appPluginsStore, $customFieldStore } = useNuxtApp()
56
+ const route = useRoute();
57
+ let xorg = this.getCurrentXorg()
58
+
59
+ let apiurl=''
60
+ if(xorg===undefined){
61
+ apiurl = `${useRuntimeConfig().public.appUrl}/api`
62
+ }else{
63
+ apiurl = `${useRuntimeConfig().public.appUrl}/api/${xorg}`
64
+ }
67
65
 
68
- return await new PROFILEApi(undefined, apiurl, $axios)
69
- .getProfile()
70
- .then((res: AxiosResponse) => {
71
- if (!res) {
72
- return;
66
+ $appPluginsStore.loadInstalledPlugins();
67
+ $customFieldStore.fetchList();
68
+
69
+ return await new PROFILEApi(undefined,apiurl,$axios).getProfile().then((res:AxiosResponse)=>{
70
+ if(!res){
71
+ return
72
+ }
73
+ this._id = res.data._id
74
+ this.sessionId = res.data.sessionId
75
+ this.tenantId = res.data.tenantId
76
+ this.orgId = res.data.orgId
77
+ this.orgRecordId = res.data.orgRecordId
78
+ this.branchId = res.data.branchId
79
+ this.branchRecordId = res.data.branchRecordId
80
+ this.branchCode = res.data.branchCode
81
+ this.branchName = res.data.branchName
82
+ this.orgCode = res.data.orgCode
83
+ this.orgName = res.data.orgName
84
+ this.timeZone = res.data.timeZone
85
+ this.currency = res.data.currency
86
+ this.country = res.data.country
87
+ this.offsetMinute = res.data.offsetMinute
88
+ this.uid = res.data.uid
89
+ this.email = res.data.email
90
+ this.fullName = res.data.fullName
91
+ this.branches = res.data.branches
92
+ this.groups = res.data.groups
93
+ this.roles = res.data.roles
94
+ this.time = res.data.time
95
+ this.invites = res.data.invites
96
+ this.moreProps = res.data.moreProps
97
+ this.package = res.data.moreProps.package;
98
+ this.appintegration.einvoice = res.data.appintegration.einvoice;
99
+ this.appintegration.simbiz6 = res.data.appintegration.simbiz6;
100
+ let cachegroup = useCookie('currentGroup').value ?? ''
101
+ if(!this.groups || !this.groups.includes(cachegroup)){
102
+ cachegroup=''
103
+ }
104
+ this.currentGroup = cachegroup
105
+ useNuxtApp().$event('pickGroup',cachegroup)
106
+ return Promise.resolve(true)
107
+ // return true
108
+ }).catch((err:any)=>{
109
+ return Promise.reject(err)
110
+ })
111
+ },
112
+ getCurrentXorg(){
113
+ return (useRoute().params.xorg) ? <String>useRoute().params.xorg : undefined
114
+ },
115
+ async pingSession():Promise<string>{
116
+ let xorg = this.getCurrentXorg()
117
+ let apiurl=''
118
+
119
+ if(!xorg){
120
+ apiurl = `${useRuntimeConfig().public.appUrl}/api`
121
+ }else{
122
+ try{
123
+ const xorgdecode = atob(<string>xorg)
124
+ if(xorgdecode.includes('-')){
125
+ apiurl = `${useRuntimeConfig().public.appUrl}/api/${xorg}`
126
+ }else{
127
+ return Promise.reject('wrongxorg')
128
+ }
129
+ }catch(e){
130
+ return Promise.reject('wrongxorg')
131
+ }
132
+
133
+
73
134
  }
74
- this._id = res.data._id;
75
- this.sessionId = res.data.sessionId;
76
- this.tenantId = res.data.tenantId;
77
- this.orgId = res.data.orgId;
78
- this.orgRecordId = res.data.orgRecordId;
79
- this.branchId = res.data.branchId;
80
- this.branchRecordId = res.data.branchRecordId;
81
- this.branchCode = res.data.branchCode;
82
- this.branchName = res.data.branchName;
83
- this.orgCode = res.data.orgCode;
84
- this.orgName = res.data.orgName;
85
- this.timeZone = res.data.timeZone;
86
- this.currency = res.data.currency;
87
- this.country = res.data.country;
88
- this.offsetMinute = res.data.offsetMinute;
89
- this.uid = res.data.uid;
90
- this.email = res.data.email;
91
- this.fullName = res.data.fullName;
92
- this.branches = res.data.branches;
93
- this.groups = res.data.groups;
94
- this.roles = res.data.roles;
95
- this.time = res.data.time;
96
- this.invites = res.data.invites;
97
- this.moreProps = res.data.moreProps;
98
- this.package = res.data.moreProps.package;
99
- this.appintegration.einvoice = res.data.appintegration.einvoice;
100
- this.appintegration.simbiz6 = res.data.appintegration.simbiz6;
101
- let cachegroup = useCookie("currentGroup").value ?? "";
102
- if (!this.groups || !this.groups.includes(cachegroup)) {
103
- cachegroup = "";
135
+ const {$axios} = useNuxtApp()
136
+ try{
137
+ const pingresult = await new PROFILEApi(undefined,apiurl).getSession()
138
+ if(pingresult.status<300)
139
+ return Promise.resolve('ok')
140
+ else
141
+ return Promise.reject('relogin')
142
+ }catch(e){
143
+ return Promise.reject(e)
104
144
  }
105
- this.currentGroup = cachegroup;
106
- useNuxtApp().$event("pickGroup", cachegroup);
107
- return Promise.resolve(true);
108
- // return true
109
- })
110
- .catch((err: any) => {
111
- return Promise.reject(err);
112
- });
113
- },
114
- getCurrentXorg() {
115
- return useRoute().params.xorg
116
- ? <String>useRoute().params.xorg
117
- : undefined;
118
- },
119
- async pingSession(): Promise<string> {
120
- let xorg = this.getCurrentXorg();
121
- let apiurl = "";
122
-
123
- if (!xorg) {
124
- apiurl = `${useRuntimeConfig().public.appUrl}/api`;
125
- } else {
126
- try {
127
- const xorgdecode = atob(<string>xorg);
128
- if (xorgdecode.includes("-")) {
129
- apiurl = `${useRuntimeConfig().public.appUrl}/api/${xorg}`;
130
- } else {
131
- return Promise.reject("wrongxorg");
145
+
146
+ },
147
+ async decideInvitation(id:string,decision:string){
148
+ const apiurl = `${useRuntimeConfig().public.appUrl}/api`
149
+ const {$axios} = useNuxtApp()
150
+ // console.log("decideInvitation",id,decision)
151
+ const result = await new PROFILEApi(undefined,apiurl,$axios).decideInvitation(id,decision)
152
+
153
+ if(result){
154
+ // console.log(result)
155
+ }else{
156
+ // console.log(result)
132
157
  }
133
- } catch (e) {
134
- return Promise.reject("wrongxorg");
135
- }
136
- }
137
- const { $axios } = useNuxtApp();
138
- try {
139
- const pingresult = await new PROFILEApi(
140
- undefined,
141
- apiurl,
142
- ).getSession();
143
- if (pingresult.status < 300) return Promise.resolve("ok");
144
- else return Promise.reject("relogin");
145
- } catch (e) {
146
- return Promise.reject(e);
147
- }
148
- },
149
- async decideInvitation(id: string, decision: string) {
150
- const apiurl = `${useRuntimeConfig().public.appUrl}/api`;
151
- const { $axios } = useNuxtApp();
152
- // console.log("decideInvitation",id,decision)
153
- const result = await new PROFILEApi(
154
- undefined,
155
- apiurl,
156
- $axios,
157
- ).decideInvitation(id, decision);
158
+ //().then((res:AxiosResponse)=>{ }
159
+ },
160
+ checkHasHighPrivilege(){
161
+ return HIGH_PRIVILEGE_ROLES.some(permission => this.roles.includes(permission))
162
+ },
163
+ canPerform(resourcename:string,action:string):boolean{
158
164
 
159
- if (result) {
160
- // console.log(result)
161
- } else {
162
- // console.log(result)
163
- }
164
- //().then((res:AxiosResponse)=>{ }
165
- },
166
- checkHasHighPrivilege() {
167
- return HIGH_PRIVILEGE_ROLES.some((permission) =>
168
- this.roles.includes(permission),
169
- );
170
- },
171
- canPerform(resourcename: string, action: string): boolean {
172
- if (
173
- this.roles.includes("superadmin") ||
174
- this.roles.includes("tenantowner") ||
175
- this.roles.includes("superuser")
176
- ) {
177
- return true;
178
- } else if (resourcename == "Paymentverify") {
179
- if (this.roles.includes("admin") || this.roles.includes("manager")) {
180
- return true;
181
- }
182
- } else if (resourcename == "Reminder") {
183
- if (this.roles.includes("admin") || this.roles.includes("manager")) {
184
- return true;
185
- }
186
- } else if (resourcename == "Generateinvoice") {
187
- if (
188
- this.roles.includes("admin") ||
189
- this.roles.includes("manager") ||
190
- this.roles.includes("executive")
191
- ) {
192
- return true;
193
- }
194
- } else if (resourcename == "Upgradelevel") {
195
- if (
196
- this.roles.includes("admin") ||
197
- this.roles.includes("manager") ||
198
- this.roles.includes("executive")
199
- ) {
200
- return true;
201
- }
202
- } else if (resourcename == "Appintegration") {
203
- if (this.roles.includes("admin") || this.roles.includes("manager")) {
204
- return true;
205
- }
206
- } else if (resourcename == "Postingtosimbiz") {
207
- if (this.roles.includes("admin")) {
208
- return true;
209
- }
210
- } else if (resourcename == "Studentdescription") {
211
- if (
212
- this.roles.includes("admin") ||
213
- this.roles.includes("manager") ||
214
- this.roles.includes("executive")
215
- ) {
216
- return true;
217
- }
218
- } else {
219
- const checkstr = `${resourcename}:${action}`;
220
- // console.log("verify",checkstr)
221
- return this.roles.includes(checkstr);
165
+ if(
166
+ this.roles.includes('superadmin') ||
167
+ this.roles.includes('tenantowner') ||
168
+ this.roles.includes('superuser')
169
+ ){
170
+ return true
171
+ }else if( resourcename == 'Paymentverify'){
172
+ if (
173
+ this.roles.includes('admin') ||
174
+ this.roles.includes('manager')
175
+ ){
176
+ return true;
177
+ }
178
+ }
179
+ else if( resourcename == 'Reminder'){
180
+ if (
181
+ this.roles.includes('admin') ||
182
+ this.roles.includes('manager')
183
+ ){
184
+ return true;
185
+ }
186
+ }
187
+ else if( resourcename == 'Generateinvoice'){
188
+ if (
189
+ this.roles.includes('admin') ||
190
+ this.roles.includes('manager') ||
191
+ this.roles.includes('executive')
192
+ ){
193
+ return true;
194
+ }
195
+ }
196
+ else if( resourcename == 'Upgradelevel'){
197
+ if (
198
+ this.roles.includes('admin') ||
199
+ this.roles.includes('manager') ||
200
+ this.roles.includes('executive')
201
+ ){
202
+ return true;
203
+ }
204
+ }
205
+ else if( resourcename == 'Appintegration'){
206
+ if (
207
+ this.roles.includes('admin') ||
208
+ this.roles.includes('manager')
209
+ ){
210
+ return true;
211
+ }
212
+ }
213
+ else if( resourcename == 'Postingtosimbiz'){
214
+ if (
215
+ this.roles.includes('admin')
216
+ ){
217
+ return true;
218
+ }
219
+ }
220
+ else if( resourcename == 'Studentdescription'){
221
+ if (
222
+ this.roles.includes('admin') ||
223
+ this.roles.includes('manager') ||
224
+ this.roles.includes('executive')
225
+ ){
226
+ return true;
227
+ }
228
+ }
229
+ else{
230
+ const checkstr= `${resourcename}:${action}`
231
+ // console.log("verify",checkstr)
232
+ return this.roles.includes(checkstr)
233
+ }
234
+ return false;
235
+ },
236
+ haveAccess(resourcename:string){
237
+ //super admin always full access right
238
+ resourcename = _.upperFirst(resourcename)
239
+ // console.log("have access",resourcename)
240
+ if(
241
+ this.roles.includes('superadmin') ||
242
+ this.roles.includes('tenantowner') ||
243
+ this.roles.includes('superuser')
244
+ ){
245
+ return true
246
+ }
247
+ else if( resourcename == 'Paymentverify'){
248
+ if (
249
+ this.roles.includes('admin') ||
250
+ this.roles.includes('manager')
251
+ ){
252
+ return true;
253
+ }
254
+ }
255
+ for(let i=0; i< this.roles.length; i++){
256
+ const role:string = this.roles[i]
257
+ if(role.includes(resourcename)){
258
+ return true
259
+ }
260
+ }
261
+ return false
262
+ },
263
+ async logout (redirecturl:string){
264
+ const redirectdata = encodeURIComponent(redirecturl)
265
+ const { signOut } = useAuth();
266
+ const { data } = await <any>useFetch('/api/auth/logout');
267
+ // remove session
268
+ await signOut({redirect:false});
269
+ let addPath = encodeURIComponent(`/login?callbackUrl=${redirectdata}`);
270
+ const tourl= `${data.value.path}${addPath}`
271
+ navigateTo(tourl,{external:true})
272
+ },
273
+ getUserInfo(){
274
+ const userinfo:UserProfile = {
275
+ _id : this._id,
276
+ sessionId : this.sessionId,
277
+ tenantId : this.tenantId,
278
+ orgId : this.orgId,
279
+ branchId : this.branchId,
280
+ orgRecordId: this.orgRecordId,
281
+ branchRecordId: this.branchRecordId,
282
+ uid : this.uid,
283
+ email : this.email,
284
+ branchCode: this.branchCode,
285
+ branchName: this.branchName,
286
+ orgCode: this.orgCode,
287
+ orgName: this.orgName,
288
+ currency: this.currency,
289
+ timeZone: this.timeZone,
290
+ country: this.country,
291
+ offsetMinute: this.offsetMinute,
292
+ fullName : this.fullName,
293
+ branches:this.branches??[],
294
+ invites: this.invites ?? [],
295
+ roles:this.roles,
296
+ groups:this.groups,
297
+ currentGroup:this.currentGroup,
298
+ time:this.time,
299
+ moreProps: this.moreProps,
300
+ package: this.package,
301
+ appintegration: this.appintegration
302
+ }
303
+ return userinfo
304
+ },
305
+ isExecutive() {
306
+ return this.currentGroup == 'executive';
307
+ },
308
+ }
309
+ })
310
+
311
+
312
+ try{
313
+ const pingsessionres = await useUserStore().pingSession()
314
+
315
+ if(pingsessionres){
316
+ await useUserStore().loadRemoteUserInfo()
222
317
  }
223
- return false;
224
- },
225
- haveAccess(resourcename: string) {
226
- //super admin always full access right
227
- resourcename = _.upperFirst(resourcename);
228
- // console.log("have access",resourcename)
229
- if (
230
- this.roles.includes("superadmin") ||
231
- this.roles.includes("tenantowner") ||
232
- this.roles.includes("superuser")
233
- ) {
234
- return true;
235
- } else if (resourcename == "Paymentverify") {
236
- if (this.roles.includes("admin") || this.roles.includes("manager")) {
237
- return true;
318
+
319
+ }catch(e:any){
320
+
321
+ //server down, stop page
322
+ if(e == 'wrongxorg'){
323
+ navigateTo('/picktenant',{external:true})
238
324
  }
239
- }
240
- for (let i = 0; i < this.roles.length; i++) {
241
- const role: string = this.roles[i];
242
- if (role.includes(resourcename)) {
243
- return true;
325
+ else if(e?.code=='ERR_BAD_RESPONSE'){
326
+ throw createError({
327
+ statusCode:e.code,
328
+ statusMessage:e.message,
329
+ fatal:true
330
+ })
331
+ }else if(e?.response?.status==302){ //no session
332
+ //need authentication, relogin
333
+ if( useRoute().meta.auth !==false){
334
+ await useUserStore().logout(useRoute().path)
335
+ }
336
+ else {
337
+ //pulic page, do nothing`
338
+ return {
339
+ provide: {
340
+ userstore:useUserStore()
341
+ }
342
+ }
343
+
344
+ }
244
345
  }
245
- }
246
- return false;
247
- },
248
- async logout(redirecturl: string) {
249
- const redirectdata = encodeURIComponent(redirecturl);
250
- const { signOut } = useAuth();
251
- const { data } = await (<any>useFetch("/api/auth/logout"));
252
- // remove session
253
- await signOut({ redirect: false });
254
- let addPath = encodeURIComponent(`/login?callbackUrl=${redirectdata}`);
255
- const tourl = `${data.value.path}${addPath}`;
256
- navigateTo(tourl, { external: true });
257
- },
258
- getUserInfo() {
259
- const userinfo: UserProfile = {
260
- _id: this._id,
261
- sessionId: this.sessionId,
262
- tenantId: this.tenantId,
263
- orgId: this.orgId,
264
- branchId: this.branchId,
265
- orgRecordId: this.orgRecordId,
266
- branchRecordId: this.branchRecordId,
267
- uid: this.uid,
268
- email: this.email,
269
- branchCode: this.branchCode,
270
- branchName: this.branchName,
271
- orgCode: this.orgCode,
272
- orgName: this.orgName,
273
- currency: this.currency,
274
- timeZone: this.timeZone,
275
- country: this.country,
276
- offsetMinute: this.offsetMinute,
277
- fullName: this.fullName,
278
- branches: this.branches ?? [],
279
- invites: this.invites ?? [],
280
- roles: this.roles,
281
- groups: this.groups,
282
- currentGroup: this.currentGroup,
283
- time: this.time,
284
- moreProps: this.moreProps,
285
- package: this.package,
286
- appintegration: this.appintegration,
287
- };
288
- return userinfo;
289
- },
290
- isExecutive() {
291
- return this.currentGroup == "executive";
292
- },
293
- },
294
- });
346
+ // else
347
+ //
348
+ }
349
+
295
350
 
296
- try {
297
- const pingsessionres = await useUserStore().pingSession();
298
351
 
299
- if (pingsessionres) {
300
- await useUserStore().loadRemoteUserInfo();
301
- }
302
- } catch (e: any) {
303
- //server down, stop page
304
- if (e == "wrongxorg") {
305
- navigateTo("/picktenant", { external: true });
306
- } else if (e?.code == "ERR_BAD_RESPONSE") {
307
- throw createError({
308
- statusCode: e.code,
309
- statusMessage: e.message,
310
- fatal: true,
311
- });
312
- } else if (e?.response?.status == 302) {
313
- //no session
314
- //need authentication, relogin
315
- if (useRoute().meta.auth !== false) {
316
- await useUserStore().logout(useRoute().path);
317
- } else {
318
- //pulic page, do nothing`
319
- return {
352
+ return {
320
353
  provide: {
321
- userstore: useUserStore(),
322
- },
323
- };
354
+ userstore:useUserStore()
355
+ }
324
356
  }
325
- }
326
- // else
327
- //
328
- }
329
-
330
- return {
331
- provide: {
332
- userstore: useUserStore(),
333
- },
334
- };
335
- // }else{
336
-
337
- // console.log("No need auth")
338
- // return true
339
- // }
357
+ // }else{
358
+
359
+ // console.log("No need auth")
360
+ // return true
361
+ // }
362
+
363
+
364
+
340
365
  });