Authentication error reporting

This commit is contained in:
Jiang Yio 2023-05-29 18:33:34 -04:00
parent 4a3136a766
commit 48a092432c

View File

@ -7,7 +7,7 @@
<div class="accordion-body" v-else> <div class="accordion-body" v-else>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<p class="card-text row"><code class="col" v-if="banner"><pre>{{banner.join('\n')}}</pre></code><code class="col" v-if="user"><pre>{{user.join('\n')}}</pre></code></p> <p class="card-text row"><code class="col" v-if="banner"><pre>{{banner.join('\n')}}</pre></code><code class="col" v-if="authinfo"><pre v-if="(authinfo.greeting) && (authinfo.greeting.length > 0)">{{authinfo.greeting.join('\n').replace(/^\n+|\s+$/gm, '')}}</pre><pre v-if="user">{{user.join('\n')}}</pre></code></p>
</div> </div>
<button class="btn btn-danger" style="width: 100%;" type="button" v-if="user" v-on:click="logout">Logout</button> <button class="btn btn-danger" style="width: 100%;" type="button" v-if="user" v-on:click="logout">Logout</button>
<div class="input-group flex-nowrap" v-if="!user"> <div class="input-group flex-nowrap" v-if="!user">
@ -142,11 +142,22 @@
}, },
async login(evt) { async login(evt) {
if(this.x_client) { if(this.x_client) {
this.authinfo = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate()); try {
if(this.authinfo.duz) { this.authinfo = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate());
var user = await this.x_client.XUS_GET_USER_INFO(); if(this.authinfo.duz) {
this.x_user = user[0] ? user : null var user = await this.x_client.XUS_GET_USER_INFO();
} else this.x_user = null; this.x_user = user[0] ? user : null
} else {
this.x_user = null;
if(this.authinfo.message) window.alert(this.authinfo.message);
else window.alert('Authentication failed.');
}
} catch(ex) {
this.authinfo = this.x_user = null;
console.warn(ex);
if(ex.name) window.alert(ex.name);
else window.alert('Authentication failed.');
}
this.$emit('update:user', this.x_user); this.$emit('update:user', this.x_user);
this.show = !this.x_user; this.show = !this.x_user;
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result); this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);