Fix getLink "next" button logic

Now, don't use the "onBlur" event, always load loginFlown from handleLogin.
This commit is contained in:
N-Pex 2023-10-31 13:01:53 +01:00
parent 80a002603a
commit d80cefd05d

View file

@ -5,20 +5,19 @@
<div class="getlink-title">{{ $t("getlink.title") }}</div> <div class="getlink-title">{{ $t("getlink.title") }}</div>
<div class="getlink-info">{{ $t("getlink.info") }}</div> <div class="getlink-info">{{ $t("getlink.info") }}</div>
<div color="rgba(255,255,255,0.1)" class="text-center"> <div color="rgba(255,255,255,0.1)" class="text-center">
<v-form v-model="isValid"> <v-form v-model="isValid" ref="form">
<v-text-field v-model="user.user_id" :label="$t('getlink.username')" color="black" background-color="white" solo <v-text-field v-model="user.user_id" :label="$t('getlink.username')" color="black" background-color="white" solo
:rules="[(v) => !!v || $t('login.username_required')]" :error="userErrorMessage != null" :rules="[(v) => !!v || $t('login.username_required')]" :error="userErrorMessage != null"
:error-messages="userErrorMessage" required v-on:keyup.enter="onUsernameEnter" v-on:keydown="hasError = false" :error-messages="userErrorMessage" required v-on:keyup.enter="onUsernameEnter" v-on:keydown="hasError = false"></v-text-field>
v-on:blur="onUsernameBlur"></v-text-field>
<div class="error--text" v-if="loadingLoginFlows">Loading login flows...</div> <!-- <div class="error--text" v-if="loadingLoginFlows">Loading login flows...</div> -->
<div class="error--text" v-if="hasError">{{ this.message }}</div> <div class="error--text" v-if="hasError">{{ this.message }}</div>
<interactive-auth ref="interactiveAuth" /> <interactive-auth ref="interactiveAuth" />
<v-btn id="btn-login" :disabled="!isValid || loading" color="primary" depressed block <v-btn id="btn-login" :disabled="!isValid || loading" color="primary" depressed block @click.stop="handleLogin"
@click.stop="handleLogin" :loading="loading" class="filled-button mt-4">{{ $t("getlink.next") }}</v-btn> :loading="loading" class="filled-button mt-4">{{ $t("getlink.next") }}</v-btn>
<v-btn color="black" depressed text block @click.stop="goToLoginPage" class="text-button">{{ $t("menu.login") <v-btn color="black" depressed text block @click.stop="goToLoginPage" class="text-button">{{ $t("menu.login")
}}</v-btn> }}</v-btn>
</v-form> </v-form>
@ -113,6 +112,7 @@ export default {
// Reset // Reset
const obj = this.defaultData(); const obj = this.defaultData();
Object.keys(obj).forEach(k => this[k] = obj[k]); Object.keys(obj).forEach(k => this[k] = obj[k]);
this.$refs.form.reset();
}) })
}, },
goToLoginPage() { goToLoginPage() {
@ -143,8 +143,9 @@ export default {
this.loading = true; this.loading = true;
this.onUsernameBlur().then(() => this.loadLoginFlows().then(() => {
this.$store.dispatch("createUser", { user, registrationFlowHandler: this.$refs.interactiveAuth.registrationFlowHandler })) return this.$store.dispatch("createUser", { user, registrationFlowHandler: this.$refs.interactiveAuth.registrationFlowHandler })
})
.then( .then(
(ignoreduser) => { (ignoreduser) => {
this.$matrix.setUserDisplayName(userDisplayName); this.$matrix.setUserDisplayName(userDisplayName);
@ -186,9 +187,9 @@ export default {
this.$navigation.push({ name: "CreateRoom" }); this.$navigation.push({ name: "CreateRoom" });
}, },
onUsernameEnter() { onUsernameEnter() {
this.onUsernameBlur(); this.handleLogin();
}, },
onUsernameBlur() { loadLoginFlows() {
var user = Object.assign({}, this.user); var user = Object.assign({}, this.user);
user.normalize(); user.normalize();
const server = user.home_server || this.$config.defaultServer; const server = user.home_server || this.$config.defaultServer;