feat: lots more improvements
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -5,10 +5,9 @@ import {
|
||||
IdentityOAuth,
|
||||
IdentityToken,
|
||||
} from '@KTXM/MailManager/models/identity'
|
||||
import type { ServiceObject } from '@KTXM/MailManager/models/service'
|
||||
import { ServiceObject } from '@KTXM/MailManager/models/service'
|
||||
import type { ServiceIdentity } from '@KTXM/MailManager/types/service'
|
||||
import type { ProviderAuthPanelProps, ProviderAuthPanelEmits } from '@KTXM/MailManager/types/integration'
|
||||
import { JmapServiceObject } from '@/models/JmapServiceObject'
|
||||
|
||||
const props = defineProps<ProviderAuthPanelProps>()
|
||||
const emit = defineEmits<ProviderAuthPanelEmits>()
|
||||
@@ -95,8 +94,30 @@ watch(
|
||||
return
|
||||
}
|
||||
|
||||
const nextService = createServiceObject(props.service)
|
||||
nextService.identity = createIdentityModel(identity)
|
||||
const nextService = props.service ?? new ServiceObject()
|
||||
const nextIdentity = createIdentityModel(identity)
|
||||
|
||||
if (nextIdentity === null) {
|
||||
nextService.identity = null
|
||||
emit('update:service', nextService)
|
||||
return
|
||||
}
|
||||
|
||||
if (nextIdentity instanceof IdentityBasic && nextService.identity instanceof IdentityBasic) {
|
||||
nextService.identity.identity = nextIdentity.identity
|
||||
nextService.identity.secret = nextIdentity.secret
|
||||
} else if (nextIdentity instanceof IdentityToken && nextService.identity instanceof IdentityToken) {
|
||||
nextService.identity.token = nextIdentity.token
|
||||
} else if (nextIdentity instanceof IdentityOAuth && nextService.identity instanceof IdentityOAuth) {
|
||||
nextService.identity.accessToken = nextIdentity.accessToken
|
||||
nextService.identity.accessScope = nextIdentity.accessScope
|
||||
nextService.identity.accessExpiry = nextIdentity.accessExpiry
|
||||
nextService.identity.refreshToken = nextIdentity.refreshToken
|
||||
nextService.identity.refreshLocation = nextIdentity.refreshLocation
|
||||
} else {
|
||||
nextService.identity = nextIdentity
|
||||
}
|
||||
|
||||
emit('update:service', nextService)
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
@@ -146,16 +167,6 @@ function syncFromService(service?: ServiceObject) {
|
||||
}
|
||||
}
|
||||
|
||||
function createServiceObject(service?: ServiceObject): JmapServiceObject {
|
||||
const nextService = new JmapServiceObject()
|
||||
|
||||
if (service) {
|
||||
nextService.fromJson(service.toJson())
|
||||
}
|
||||
|
||||
return nextService
|
||||
}
|
||||
|
||||
function createIdentityModel(identity: ServiceIdentity | null) {
|
||||
if (identity === null) {
|
||||
return null
|
||||
@@ -174,6 +185,8 @@ function createIdentityModel(identity: ServiceIdentity | null) {
|
||||
identity.refreshToken,
|
||||
identity.refreshLocation
|
||||
)
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,13 +234,8 @@ async function initiateOAuth() {
|
||||
<h3 class="text-h6 mb-4">Authentication</h3>
|
||||
<p class="text-body-2 mb-6">Choose your authentication method and enter your credentials.</p>
|
||||
|
||||
<v-alert type="info" variant="tonal" class="mb-4">
|
||||
<template #prepend>
|
||||
<v-icon>mdi-information</v-icon>
|
||||
</template>
|
||||
<div class="text-caption">
|
||||
JMAP supports multiple authentication methods. Choose the one your server uses.
|
||||
</div>
|
||||
<v-alert type="info" variant="tonal">
|
||||
JMAP supports multiple authentication methods. Choose the one your server uses.
|
||||
</v-alert>
|
||||
|
||||
<!-- Authentication Type Selection -->
|
||||
|
||||
Reference in New Issue
Block a user