Add use url scheme option to account auth

This commit is contained in:
kPherox 2019-04-30 14:55:24 +09:00
parent f5d63e647a
commit 70e26885dc
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -1,5 +1,6 @@
<template> <template>
<form @submit.prevent="authCode" v-if="inputCode"> <div v-if="useURLScheme && inputCode">Wait Authorize TheDesk.</div>
<form @submit.prevent="authCode" v-else-if="inputCode">
<BaseInputText placeholder="input code" v-model="code"/> <BaseInputText placeholder="input code" v-model="code"/>
<BaseButton <BaseButton
type="submit" type="submit"
@ -16,6 +17,9 @@
style="--font-size:.8em;" style="--font-size:.8em;"
:disabled="this.domain === ''" :disabled="this.domain === ''"
>Login</BaseButton> >Login</BaseButton>
<label>
<input type="checkbox" v-model="useURLScheme">Use URL Scheme
</label>
</form> </form>
</template> </template>
@ -37,6 +41,7 @@ export default class AccountAuth extends Vue {
public instance: Instance = "" public instance: Instance = ""
public code: string = "" public code: string = ""
public domain: string = "" public domain: string = ""
public useURLScheme: boolean = false
public get inputCode(): boolean { public get inputCode(): boolean {
return this.instance !== "" return this.instance !== ""
@ -45,7 +50,15 @@ export default class AccountAuth extends Vue {
public addAccount() { public addAccount() {
this.instance = this.domain this.instance = this.domain
this.domain = "" this.domain = ""
ipcRenderer.send(`new-account-setup`, this.instance) if (this.useURLScheme) {
ipcRenderer.once('open-url-scheme', (e: Event, urlString: string) => {
let url: URL = new URL(urlString)
let params: URLSearchParams = url.searchParams
this.code = params.get('code') || ''
this.authCode()
})
}
ipcRenderer.send(`new-account-setup`, this.instance, this.useURLScheme)
} }
public authCode() { public authCode() {
ipcRenderer.once( ipcRenderer.once(