Authentication result parsing

This commit is contained in:
2023-05-29 18:32:13 -04:00
parent 0f019ebc34
commit 4a3136a766
7 changed files with 26 additions and 26 deletions

View File

@ -81,6 +81,7 @@
x_server: this.server,
x_user: this.user,
banner: null,
authinfo: null,
accesscode: null,
verifycode: null
};
@ -121,7 +122,7 @@
this.logout();
if(this.x_client = await (this.host ? vistax.Client.fromCookie(this.secret, this.host) : vistax.Client.fromCookie(this.secret))) {
this.banner = await this.x_client.XUS_INTRO_MSG();
if((await this.x_client.userinfo()).result) try {
if((this.authinfo = await this.x_client.authinfo()).success) try {
var user = await this.x_client.XUS_GET_USER_INFO();
this.x_user = user[0] ? user : null
} catch(ex) {
@ -136,20 +137,21 @@
} else {
this.fail = true;
this.host = undefined;
this.authinfo = null;
}
},
async login(evt) {
if(this.x_client) {
var res = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate());
if(!!res.result[0]) {
this.authinfo = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate());
if(this.authinfo.duz) {
var user = await this.x_client.XUS_GET_USER_INFO();
this.x_user = user[0] ? user : null
} else this.x_user = null;
this.$emit('update:user', this.x_user);
this.show = !this.x_user;
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
console.log('Authenticate', res);
}
console.log('Authenticate', this.authinfo);
} else this.authinfo = null;
},
async logout(evt) {
if(this.x_client) {