@zvonimirsun/iszy-nuxt-auth-layer 0.1.7 → 0.1.8

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.
@@ -23,13 +23,13 @@ const showAdminLink = computed(() => {
23
23
 
24
24
  /** ************** 三方登录绑定 ***************/
25
25
 
26
- type ThirdPartyType = 'github' | 'linuxdo' | 'sso'
26
+ type LoginProviderType = 'github' | 'linuxdo' | 'sso'
27
27
  type ThirdPartyProfile = {
28
- [key in ThirdPartyType]?: string
28
+ [key in LoginProviderType]?: string
29
29
  }
30
30
 
31
31
  const thirdParties: {
32
- type: ThirdPartyType
32
+ type: Exclude<LoginProviderType, 'sso'>
33
33
  title: string
34
34
  icon: string
35
35
  }[] = [
@@ -43,13 +43,14 @@ const thirdParties: {
43
43
  title: 'LINUX DO',
44
44
  icon: 'i-iszy-auth:linuxdo',
45
45
  },
46
- {
47
- type: 'sso',
48
- title: authFeatures.sso.title,
49
- icon: 'i-lucide:shield-check',
50
- },
51
46
  ]
52
47
 
48
+ const ssoProvider = {
49
+ type: 'sso' as const,
50
+ title: authFeatures.sso.title,
51
+ icon: 'i-lucide:shield-check',
52
+ }
53
+
53
54
  const binding = ref(false)
54
55
  let pollIndex: number | null = null
55
56
 
@@ -61,7 +62,7 @@ onBeforeUnmount(() => {
61
62
  window.removeEventListener('message', bindCallback)
62
63
  })
63
64
 
64
- async function bind(type: ThirdPartyType, title = '绑定第三方登录', width = 500, height = 600) {
65
+ async function bind(type: LoginProviderType, title = '绑定第三方登录', width = 500, height = 600) {
65
66
  if (isThirdPartyBound(type)) {
66
67
  return
67
68
  }
@@ -117,7 +118,7 @@ async function bindCallback(e: MessageEvent<{
117
118
  }
118
119
  }
119
120
 
120
- async function unbind(type: ThirdPartyType) {
121
+ async function unbind(type: LoginProviderType) {
121
122
  if (!isThirdPartyBound(type)) {
122
123
  return
123
124
  }
@@ -130,7 +131,7 @@ async function unbind(type: ThirdPartyType) {
130
131
  }
131
132
  }
132
133
 
133
- function isThirdPartyBound(type: ThirdPartyType) {
134
+ function isThirdPartyBound(type: LoginProviderType) {
134
135
  return !!(userStore.profile as ThirdPartyProfile | undefined)?.[type]
135
136
  }
136
137
 
@@ -302,6 +303,22 @@ async function removeDevice(options: {
302
303
  </div>
303
304
  </div>
304
305
  </div>
306
+ <div class="flex items-start gap-2">
307
+ <div class="w-20 text-right">
308
+ {{ ssoProvider.title }}:
309
+ </div>
310
+ <div class="flex gap-2 items-center">
311
+ <div class="flex gap-2 items-center">
312
+ <UIcon :name="ssoProvider.icon" class="size-5" />
313
+ </div>
314
+ <UButton v-if="isThirdPartyBound(ssoProvider.type)" variant="link" class="p-0 cursor-pointer" @click="unbind(ssoProvider.type)">
315
+ 解绑
316
+ </UButton>
317
+ <UButton v-else variant="link" class="p-0 cursor-pointer" @click="bind(ssoProvider.type, ssoProvider.title)">
318
+ 绑定
319
+ </UButton>
320
+ </div>
321
+ </div>
305
322
  </div>
306
323
  <div class="flex gap-2">
307
324
  <UModal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zvonimirsun/iszy-nuxt-auth-layer",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "ISZY Nuxt 应用共享认证 layer。",