feat: add oauth callback email binding ui
This commit is contained in:
@@ -30,6 +30,20 @@ describe('oauth adoption auth api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('posts bind-login decisions when finalizing pending oauth bind flow', async () => {
|
||||
const { completePendingOAuthBindLogin } = await import('@/api/auth')
|
||||
|
||||
await completePendingOAuthBindLogin({
|
||||
adoptDisplayName: true,
|
||||
adoptAvatar: false
|
||||
})
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/auth/oauth/pending/exchange', {
|
||||
adopt_display_name: true,
|
||||
adopt_avatar: false
|
||||
})
|
||||
})
|
||||
|
||||
it('posts linuxdo invitation completion with adoption decisions', async () => {
|
||||
const { completeLinuxDoOAuthRegistration } = await import('@/api/auth')
|
||||
|
||||
@@ -45,6 +59,21 @@ describe('oauth adoption auth api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('posts linuxdo create-account completion with adoption decisions', async () => {
|
||||
const { createPendingLinuxDoOAuthAccount } = await import('@/api/auth')
|
||||
|
||||
await createPendingLinuxDoOAuthAccount('invite-code', {
|
||||
adoptDisplayName: false,
|
||||
adoptAvatar: true
|
||||
})
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/auth/oauth/linuxdo/complete-registration', {
|
||||
invitation_code: 'invite-code',
|
||||
adopt_display_name: false,
|
||||
adopt_avatar: true
|
||||
})
|
||||
})
|
||||
|
||||
it('posts oidc invitation completion with adoption decisions', async () => {
|
||||
const { completeOIDCOAuthRegistration } = await import('@/api/auth')
|
||||
|
||||
@@ -60,6 +89,21 @@ describe('oauth adoption auth api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('posts oidc create-account completion with adoption decisions', async () => {
|
||||
const { createPendingOIDCOAuthAccount } = await import('@/api/auth')
|
||||
|
||||
await createPendingOIDCOAuthAccount('invite-code', {
|
||||
adoptDisplayName: true,
|
||||
adoptAvatar: false
|
||||
})
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/auth/oauth/oidc/complete-registration', {
|
||||
invitation_code: 'invite-code',
|
||||
adopt_display_name: true,
|
||||
adopt_avatar: false
|
||||
})
|
||||
})
|
||||
|
||||
it('posts wechat invitation completion with adoption decisions', async () => {
|
||||
const { completeWeChatOAuthRegistration } = await import('@/api/auth')
|
||||
|
||||
@@ -75,6 +119,21 @@ describe('oauth adoption auth api', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('posts wechat create-account completion with adoption decisions', async () => {
|
||||
const { createPendingWeChatOAuthAccount } = await import('@/api/auth')
|
||||
|
||||
await createPendingWeChatOAuthAccount('invite-code', {
|
||||
adoptDisplayName: false,
|
||||
adoptAvatar: false
|
||||
})
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/auth/oauth/wechat/complete-registration', {
|
||||
invitation_code: 'invite-code',
|
||||
adopt_display_name: false,
|
||||
adopt_avatar: false
|
||||
})
|
||||
})
|
||||
|
||||
it('classifies oauth completion results as login or bind', async () => {
|
||||
const { getOAuthCompletionKind } = await import('@/api/auth')
|
||||
|
||||
@@ -82,6 +141,38 @@ describe('oauth adoption auth api', () => {
|
||||
expect(getOAuthCompletionKind({ redirect: '/profile' })).toBe('bind')
|
||||
})
|
||||
|
||||
it('provides bind-login utility helpers for invitation and suggested profile states', async () => {
|
||||
const {
|
||||
getPendingOAuthBindLoginKind,
|
||||
hasPendingOAuthSuggestedProfile,
|
||||
isPendingOAuthCreateAccountRequired
|
||||
} = await import('@/api/auth')
|
||||
|
||||
expect(getPendingOAuthBindLoginKind({ access_token: 'access-token' })).toBe('login')
|
||||
expect(getPendingOAuthBindLoginKind({ redirect: '/profile' })).toBe('bind')
|
||||
expect(
|
||||
isPendingOAuthCreateAccountRequired({
|
||||
error: 'invitation_required'
|
||||
})
|
||||
).toBe(true)
|
||||
expect(
|
||||
isPendingOAuthCreateAccountRequired({
|
||||
error: 'other'
|
||||
})
|
||||
).toBe(false)
|
||||
expect(
|
||||
hasPendingOAuthSuggestedProfile({
|
||||
suggested_display_name: 'OAuth Nick'
|
||||
})
|
||||
).toBe(true)
|
||||
expect(
|
||||
hasPendingOAuthSuggestedProfile({
|
||||
suggested_avatar_url: 'https://cdn.example/avatar.png'
|
||||
})
|
||||
).toBe(true)
|
||||
expect(hasPendingOAuthSuggestedProfile({})).toBe(false)
|
||||
})
|
||||
|
||||
it('prepares an oauth bind access token cookie before redirect binding', async () => {
|
||||
localStorage.setItem('auth_token', 'access-token-value')
|
||||
const setCookie = vi.fn()
|
||||
|
||||
Reference in New Issue
Block a user