@live-change/user-frontend 0.8.63 → 0.8.65

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.
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <div class="w-full lg:w-6 md:w-9" v-shared-element:form="{ duration: '300ms', includeChildren: true }">
3
+ <div class="surface-card p-4 shadow-2 border-round">
4
+
5
+ <div class="text-center mb-5">
6
+ <div class="text-900 text-3xl font-medium mb-3">Linkedin authentication</div>
7
+ </div>
8
+
9
+ <div v-if="state === 'canceled'" class="text-center">
10
+ <div class="mb-2 text-red-500">Authentication canceled by user</div>
11
+ <div class="flex flex-row">
12
+ <Button @click="back" label="Go back" icon="pi pi-arrow-left"
13
+ class="w-full p-button-secondary mb-1" />
14
+ </div>
15
+ </div>
16
+ <div v-else-if="state === 'working'" class="text-center">
17
+ Waiting for server...
18
+ </div>
19
+ <div v-else-if="state === 'error'" class="text-center">
20
+ <div>Error during authentication</div>
21
+ <div>{{ error }}</div>
22
+ </div>
23
+ <div v-else>
24
+ Unknown authentication state: {{ state }}
25
+ </div>
26
+
27
+ </div>
28
+ </div>
29
+ </template>
30
+
31
+ <script setup>
32
+ import { defineProps, toRefs, ref, onMounted, inject } from 'vue'
33
+
34
+ import { useApi } from "@live-change/vue3-ssr"
35
+ const api = useApi()
36
+
37
+ import { useToast } from 'primevue/usetoast'
38
+ const toast = useToast()
39
+
40
+ const workingZone = inject('workingZone')
41
+
42
+ import { useRouter, useRoute } from 'vue-router'
43
+ const router = useRouter()
44
+ const route = useRoute()
45
+
46
+ const props = defineProps({
47
+ action: {
48
+ type: String,
49
+ default: 'signInOrSignUp'
50
+ }
51
+ })
52
+
53
+ const { action } = toRefs(props)
54
+ const state = ref('waiting')
55
+ const error = ref(null)
56
+
57
+ onMounted(async () => {
58
+ const query = route.query
59
+ console.log("QUERY", query)
60
+
61
+ if(!query.code) {
62
+ state.value = 'canceled'
63
+ return
64
+ }
65
+ try {
66
+ const result = await workingZone.addPromise(`linkedin ${action.value}`,
67
+ api.command(['linkedinAuthentication', action.value], {
68
+ redirectUri: document.location.protocol + '//' + document.location.host
69
+ + router.resolve({ name: 'user:linkedinAuthReturn', params: { action: action.value } }).href,
70
+ ...query
71
+ })
72
+ )
73
+ console.log("LINKEDIN AUTH RESULT", result)
74
+ const { action: actionDone, user } = result
75
+ while(user && api.client.value.user !== user) {
76
+ await new Promise(resolve => setTimeout(resolve, 100))
77
+ }
78
+ if(actionDone === 'signIn') {
79
+ router.push({ name: 'user:signInFinished' })
80
+ } else if(actionDone === 'signUp') {
81
+ router.push({ name: 'user:signUpFinished' })
82
+ } else if(actionDone === 'connectLinkedin') {
83
+ router.push({ name: 'user:connected' })
84
+ } else if(actionDone === 'addOfflineAccessToken') {
85
+ router.push({ name: 'user:linkedin-access-gained' })
86
+ } else {
87
+ console.error("Unknown action", actionDone)
88
+ }
89
+ } catch(error) {
90
+ console.error("Linkedin auth error", error)
91
+ toast.add({ severity: 'error', summary: 'Error', detail: 'Error during linkedin authentication', life: 3000 })
92
+ state.value = 'error'
93
+ error.value = error
94
+ }
95
+ })
96
+
97
+ async function back() {
98
+ router.go(-1)
99
+ }
100
+
101
+ </script>
102
+
103
+ <style scoped>
104
+
105
+ </style>
@@ -59,6 +59,14 @@
59
59
  />
60
60
  </router-link>
61
61
 
62
+ <router-link :to="{ name: 'user:linkedinAuth', params: { action: 'signInOrSignUp' } }" class="no-underline">
63
+ <Button
64
+ label="Sign In with Linkedin"
65
+ icon="pi pi-linkedin"
66
+ class="w-full p-button-secondary mb-1"
67
+ />
68
+ </router-link>
69
+
62
70
  </div>
63
71
  </div>
64
72
  </template>
@@ -10,6 +10,14 @@ export function routes(config = {}) {
10
10
  route({ name: 'user:googleAuthReturn', path: prefix + 'google-auth-return/:action',
11
11
  component: () => import("./GoogleAuthReturn.vue"), props: true }),
12
12
 
13
+ route({ name: 'user:linkedinAuth', path: prefix + 'linkedin-auth/:action',
14
+ component: () => import("./LinkedinAuth.vue"), props: true, meta: { } }),
15
+ route({ name: 'user:linkedinAuthScopes', path: prefix + 'linkedin-auth/:action/:scopes*',
16
+ component: () => import("./LinkedinAuth.vue"), props: true, meta: { } }),
17
+ route({ name: 'user:linkedinAuthReturn', path: prefix + 'linkedin-auth-return/:action',
18
+ component: () => import("./LinkedinAuthReturn.vue"), props: true }),
19
+
20
+
13
21
  route({ name: 'user:signInEmail', path: prefix + 'sign-in-email',
14
22
  component: () => import("./SignInEmail.vue"), meta: { signedOut: true } }),
15
23
  route({ name: 'user:signInFinished', path: prefix + 'sign-in-finished',