@live-change/user-frontend 0.9.26 → 0.9.28

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.
@@ -46,8 +46,8 @@
46
46
 
47
47
  const afterSignIn = ref()
48
48
  const redirectTime = ref()
49
- let timeout
50
- onMounted(() => {
49
+ let redirectTimeout
50
+ function doRedirect() {
51
51
  if(localStorage.redirectAfterSignIn) {
52
52
  const route = JSON.parse(localStorage.redirectAfterSignIn)
53
53
  localStorage.removeItem('redirectAfterSignIn')
@@ -56,23 +56,35 @@
56
56
  afterSignIn.value = route
57
57
  if(delay) {
58
58
  redirectTime.value = new Date(Date.now() + delay * 1000)
59
- timeout = setTimeout(() => {
59
+ redirectTimeout = setTimeout(() => {
60
60
  if(afterSignIn.value) {
61
61
  router.push(route)
62
62
  }
63
63
  }, redirectTime.value - currentTime.value)
64
64
  } else {
65
- toast.add({
66
- severity: 'info', life: 6000,
67
- summary: 'Signed in',
68
- detail: 'Congratulations! You have successfully logged in to your account.'
69
- })
70
- router.push(route)
65
+ setTimeout(() => { // it could be next tick
66
+ toast.add({
67
+ severity: 'info', life: 6000,
68
+ summary: 'Signed in',
69
+ detail: 'Congratulations! You have successfully logged in to your account.'
70
+ })
71
+ router.push(route)
72
+ }, 100)
71
73
  }
72
74
  }
75
+ }
76
+ let finished = false
77
+ onMounted(async () => {
78
+ console.log("WAIT FOR USER?", !finished, !api.client.value.user, !finished && !api.client.value.user)
79
+ while(!finished && !api.client.value.user) {
80
+ console.log("WAITING FOR USER...")
81
+ await new Promise(resolve => setTimeout(resolve, 200))
82
+ }
83
+ if(!finished) doRedirect()
73
84
  })
74
85
  onUnmounted(() => {
75
- clearTimeout(timeout)
86
+ finished = true
87
+ if(redirectTime.value) clearTimeout(redirectTimeout)
76
88
  })
77
89
 
78
90
  </script>
@@ -12,7 +12,7 @@
12
12
  You can now set password to secure your account.
13
13
  </span>
14
14
  <div v-else-if="afterSignIn" class="flex flex-row justify-content-center align-items-center">
15
- <router-link :to="JSON.parse(afterSignIn)" class="no-underline">
15
+ <router-link :to="afterSignIn" class="no-underline">
16
16
  <Button label="Next" v-ripple />
17
17
  </router-link>
18
18
  <p class="ml-4" v-if="isMounted && redirectTime">
@@ -87,7 +87,8 @@
87
87
  import Divider from "primevue/divider"
88
88
  import Password from "../password/Password.vue"
89
89
 
90
- import { live, path } from '@live-change/vue3-ssr'
90
+ import { live, path, useApi } from '@live-change/vue3-ssr'
91
+ const api = useApi()
91
92
  import { computed, ref, onMounted, onUnmounted } from 'vue'
92
93
 
93
94
  import { currentTime } from "@live-change/frontend-base"
@@ -120,8 +121,8 @@
120
121
 
121
122
  const afterSignIn = ref()
122
123
  const redirectTime = ref()
123
- let timeout
124
- onMounted(() => {
124
+ let redirectTimeout
125
+ function doRedirect() {
125
126
  if(localStorage.redirectAfterSignIn) {
126
127
  const route = JSON.parse(localStorage.redirectAfterSignIn)
127
128
  localStorage.removeItem('redirectAfterSignIn')
@@ -130,23 +131,35 @@
130
131
  afterSignIn.value = route
131
132
  if(delay) {
132
133
  redirectTime.value = new Date(Date.now() + delay * 1000)
133
- timeout = setTimeout(() => {
134
+ redirectTimeout = setTimeout(() => {
134
135
  if(afterSignIn.value) {
135
136
  router.push(route)
136
137
  }
137
138
  }, redirectTime.value - currentTime.value)
138
139
  } else {
139
- toast.add({
140
- severity: 'info', life: 6000,
141
- summary: 'Signed up',
142
- detail: 'Congratulations! You have successfully created your account.'
143
- })
144
- router.push(route)
140
+ setTimeout(() => { // it could be next tick
141
+ toast.add({
142
+ severity: 'info', life: 6000,
143
+ summary: 'Signed up',
144
+ detail: 'Congratulations! You have successfully created your account.'
145
+ })
146
+ router.push(route)
147
+ }, 100)
145
148
  }
146
149
  }
150
+ }
151
+ let finished = false
152
+ onMounted(async () => {
153
+ console.log("WAIT FOR USER?", !finished, !api.client.value.user, !finished && !api.client.value.user)
154
+ while(!finished && !api.client.value.user) {
155
+ console.log("WAITING FOR USER...")
156
+ await new Promise(resolve => setTimeout(resolve, 200))
157
+ }
158
+ if(!finished) doRedirect()
147
159
  })
148
160
  onUnmounted(() => {
149
- clearTimeout(timeout)
161
+ finished = true
162
+ if(redirectTime.value) clearTimeout(redirectTimeout)
150
163
  })
151
164
 
152
165
  const needPassword = computed(() => (!passwordExists.value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/user-frontend",
3
- "version": "0.9.26",
3
+ "version": "0.9.28",
4
4
  "scripts": {
5
5
  "memDev": "node --inspect --expose-gc server/start.js memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; node server/start.js localDev --enableSessions --initScript ./init.js",
@@ -22,29 +22,29 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/cli": "^0.9.26",
26
- "@live-change/dao": "^0.9.26",
27
- "@live-change/dao-vue3": "^0.9.26",
28
- "@live-change/dao-websocket": "^0.9.26",
29
- "@live-change/email-service": "^0.9.26",
30
- "@live-change/framework": "^0.9.26",
31
- "@live-change/identicon-service": "^0.9.26",
32
- "@live-change/image-frontend": "^0.9.26",
33
- "@live-change/message-authentication-service": "^0.9.26",
34
- "@live-change/notification-service": "^0.9.26",
35
- "@live-change/password-authentication-service": "^0.9.26",
36
- "@live-change/pattern": "^0.9.26",
37
- "@live-change/secret-code-service": "^0.9.26",
38
- "@live-change/secret-link-service": "^0.9.26",
39
- "@live-change/security-frontend": "^0.9.26",
40
- "@live-change/security-service": "^0.9.26",
41
- "@live-change/session-service": "^0.9.26",
42
- "@live-change/timer-service": "^0.9.26",
43
- "@live-change/upload-service": "^0.9.26",
44
- "@live-change/user-identification-service": "^0.9.26",
45
- "@live-change/user-service": "^0.9.26",
46
- "@live-change/vue3-components": "^0.9.26",
47
- "@live-change/vue3-ssr": "^0.9.26",
25
+ "@live-change/cli": "^0.9.28",
26
+ "@live-change/dao": "^0.9.28",
27
+ "@live-change/dao-vue3": "^0.9.28",
28
+ "@live-change/dao-websocket": "^0.9.28",
29
+ "@live-change/email-service": "^0.9.28",
30
+ "@live-change/framework": "^0.9.28",
31
+ "@live-change/identicon-service": "^0.9.28",
32
+ "@live-change/image-frontend": "^0.9.28",
33
+ "@live-change/message-authentication-service": "^0.9.28",
34
+ "@live-change/notification-service": "^0.9.28",
35
+ "@live-change/password-authentication-service": "^0.9.28",
36
+ "@live-change/pattern": "^0.9.28",
37
+ "@live-change/secret-code-service": "^0.9.28",
38
+ "@live-change/secret-link-service": "^0.9.28",
39
+ "@live-change/security-frontend": "^0.9.28",
40
+ "@live-change/security-service": "^0.9.28",
41
+ "@live-change/session-service": "^0.9.28",
42
+ "@live-change/timer-service": "^0.9.28",
43
+ "@live-change/upload-service": "^0.9.28",
44
+ "@live-change/user-identification-service": "^0.9.28",
45
+ "@live-change/user-service": "^0.9.28",
46
+ "@live-change/vue3-components": "^0.9.28",
47
+ "@live-change/vue3-ssr": "^0.9.28",
48
48
  "@vueuse/core": "^12.3.0",
49
49
  "codeceptjs-assert": "^0.0.5",
50
50
  "codeceptjs-video-helper": "0.1.3",
@@ -65,7 +65,7 @@
65
65
  "wtfnode": "^0.9.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@live-change/codeceptjs-helper": "^0.9.26",
68
+ "@live-change/codeceptjs-helper": "^0.9.28",
69
69
  "codeceptjs": "^3.6.10",
70
70
  "generate-password": "1.7.1",
71
71
  "playwright": "1.49.1",
@@ -76,5 +76,5 @@
76
76
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
77
77
  "license": "BSD-3-Clause",
78
78
  "description": "",
79
- "gitHead": "94bb21574dafa3649352cbffe3b25b6252c5c11b"
79
+ "gitHead": "f308e368e678fa38ddef6a6d4999ad730b18e8ce"
80
80
  }