fix: tighten pending oauth email routing and binding state
This commit is contained in:
@@ -209,7 +209,12 @@ function getBindingStatus(provider: UserAuthProvider): boolean {
|
||||
|
||||
function getBindingStatusForUser(user: User | null | undefined, provider: UserAuthProvider): boolean {
|
||||
if (provider === 'email') {
|
||||
return typeof user?.email_bound === 'boolean' ? user.email_bound : Boolean(user?.email)
|
||||
if (typeof user?.email_bound === 'boolean') {
|
||||
return user.email_bound
|
||||
}
|
||||
const nested = user?.auth_bindings?.email ?? user?.identity_bindings?.email
|
||||
const normalized = normalizeBindingStatus(nested)
|
||||
return normalized ?? false
|
||||
}
|
||||
|
||||
const directFlag = user?.[`${provider}_bound` as keyof User]
|
||||
|
||||
@@ -301,4 +301,27 @@ describe('ProfileIdentityBindingsSection', () => {
|
||||
expect(wrapper.get('[data-testid="profile-binding-email-status"]').text()).toBe('Bound')
|
||||
expect(authStore.user?.email).toBe('bound@example.com')
|
||||
})
|
||||
|
||||
it('keeps the email binding form visible when the user still lacks an email identity', () => {
|
||||
const wrapper = mount(ProfileIdentityBindingsSection, {
|
||||
global: {
|
||||
plugins: [pinia],
|
||||
},
|
||||
props: {
|
||||
user: createUser({
|
||||
email: 'legacy@example.com',
|
||||
email_bound: false,
|
||||
auth_bindings: {
|
||||
email: { bound: false },
|
||||
},
|
||||
}),
|
||||
linuxdoEnabled: false,
|
||||
oidcEnabled: false,
|
||||
wechatEnabled: false,
|
||||
},
|
||||
})
|
||||
|
||||
expect(wrapper.get('[data-testid="profile-binding-email-status"]').text()).toBe('Not bound')
|
||||
expect(wrapper.get('[data-testid="profile-binding-email-input"]').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user