Archived
2
0

autologin with URL pwd first.

This commit is contained in:
m1k1o 2021-03-12 22:24:52 +01:00
parent 577f508912
commit 108ac79443

View File

@ -151,14 +151,21 @@
@Component({ name: 'neko-connect' }) @Component({ name: 'neko-connect' })
export default class extends Vue { export default class extends Vue {
private autoPassword = new URL(location.href).searchParams.get('pwd') private autoPassword: string | null = new URL(location.href).searchParams.get('pwd')
private displayname: string = '' private displayname: string = ''
private password: string = this.autoPassword || '' private password: string = ''
mounted() { mounted() {
if (this.$accessor.displayname !== '' && this.$accessor.password !== '') { let password = this.$accessor.password
this.$accessor.login({ displayname: this.$accessor.displayname, password: this.$accessor.password }) if (this.autoPassword !== null) {
this.removeUrlParam('pwd')
password = this.autoPassword
}
if (this.$accessor.displayname !== '' && password !== '') {
this.$accessor.login({ displayname: this.$accessor.displayname, password })
this.autoPassword = null
} }
} }
@ -188,16 +195,15 @@
} }
async login() { async login() {
try { let password = this.password
await this.$accessor.login({ if (this.autoPassword !== null) {
displayname: this.displayname, password = this.autoPassword
password: this.password,
})
if (this.autoPassword) {
this.removeUrlParam('pwd')
this.autoPassword = ''
} }
try {
await this.$accessor.login({ displayname: this.displayname, password })
this.autoPassword = null
} catch (err) { } catch (err) {
this.$swal({ this.$swal({
title: this.$t('connect.error') as string, title: this.$t('connect.error') as string,