autologin with URL pwd first.
This commit is contained in:
parent
577f508912
commit
108ac79443
@ -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,
|
||||||
|
Reference in New Issue
Block a user