@zvonimirsun/iszy-nuxt-auth-layer 0.2.5 → 0.2.6

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.
@@ -209,7 +209,7 @@ async function bindCallback(e: MessageEvent<{
209
209
  }
210
210
  }
211
211
 
212
- async function unbind(type: LoginProviderType) {
212
+ async function unbind(type: Exclude<LoginProviderType, 'sso'>) {
213
213
  if (!isThirdPartyBound(type)) {
214
214
  return
215
215
  }
@@ -401,7 +401,7 @@ function getErrorMessage(error: unknown) {
401
401
  @submit="updatePassword"
402
402
  >
403
403
  <p class="text-sm text-muted">
404
- 已有登录密码时需要填写旧密码;历史 SSO 无密码账户可直接设置新密码。
404
+ 已有登录密码时需要填写旧密码;无密码账户可直接设置新密码。
405
405
  </p>
406
406
  <UFormField label="旧密码" name="oldPasswd">
407
407
  <UInput v-model="passwordState.oldPasswd" class="w-full" type="password" autocomplete="current-password" />
@@ -488,9 +488,9 @@ function getErrorMessage(error: unknown) {
488
488
  <div class="flex gap-2 items-center">
489
489
  <UIcon :name="ssoProvider.icon" class="size-5" />
490
490
  </div>
491
- <UButton v-if="isThirdPartyBound(ssoProvider.type)" variant="link" class="p-0 cursor-pointer" @click="unbind(ssoProvider.type)">
492
- 解绑
493
- </UButton>
491
+ <UBadge v-if="isThirdPartyBound(ssoProvider.type)" color="success" variant="subtle">
492
+ 已绑定
493
+ </UBadge>
494
494
  <UButton v-else variant="link" class="p-0 cursor-pointer" @click="bind(ssoProvider.type, ssoProvider.title)">
495
495
  绑定
496
496
  </UButton>
@@ -70,7 +70,7 @@ const createSchema = z.object({
70
70
  userName: z.string().trim().min(1, '请输入用户名'),
71
71
  nickName: z.string().trim().min(1, '请输入昵称'),
72
72
  email: z.string().trim().refine(value => !value || z.email().safeParse(value).success, '请输入有效的邮箱地址'),
73
- passwd: z.string().min(1, '请输入密码'),
73
+ passwd: z.string().optional(),
74
74
  })
75
75
 
76
76
  type BindSchema = z.output<typeof bindSchema>
@@ -275,8 +275,8 @@ function getErrorMessage(error: unknown, fallback: string) {
275
275
  <UFormField label="邮箱" name="email">
276
276
  <UInput v-model="createState.email" class="w-full" type="email" autocomplete="email" placeholder="请输入邮箱(可选)" />
277
277
  </UFormField>
278
- <UFormField label="密码" name="passwd" required>
279
- <UInput v-model="createState.passwd" class="w-full" type="password" autocomplete="new-password" placeholder="请输入密码" />
278
+ <UFormField label="密码(可选)" name="passwd" hint="不设置时仅可通过 SSO 登录">
279
+ <UInput v-model="createState.passwd" class="w-full" type="password" autocomplete="new-password" placeholder="可稍后在账户设置中添加" />
280
280
  </UFormField>
281
281
  <UAlert v-if="submitError" color="error" icon="i-lucide:info" :title="submitError" />
282
282
  <div class="grid grid-cols-2 gap-3">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zvonimirsun/iszy-nuxt-auth-layer",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "ISZY Nuxt 应用共享认证 layer。",
@@ -14,10 +14,10 @@ export default defineEventHandler(async (event): Promise<ResultDto<PublicSimpleU
14
14
  const nickName = body?.nickName?.trim()
15
15
  const email = body?.email?.trim() || undefined
16
16
 
17
- if (!userName || !nickName || !body?.passwd) {
17
+ if (!userName || !nickName) {
18
18
  throw createError({
19
19
  statusCode: 400,
20
- message: '用户名、昵称和密码不能为空',
20
+ message: '用户名和昵称不能为空',
21
21
  })
22
22
  }
23
23
 
@@ -30,7 +30,7 @@ export default defineEventHandler(async (event): Promise<ResultDto<PublicSimpleU
30
30
  userName,
31
31
  nickName,
32
32
  email,
33
- passwd: body.passwd,
33
+ passwd: body.passwd || undefined,
34
34
  },
35
35
  })
36
36
  }
@@ -41,7 +41,7 @@ export interface SsoCompletionCreateBody {
41
41
  userName: string
42
42
  nickName: string
43
43
  email?: string
44
- passwd: string
44
+ passwd?: string
45
45
  }
46
46
 
47
47
  export interface AuthTokenData {