From 312536f66dfc5252ba15fbe55087ae269877cdd4 Mon Sep 17 00:00:00 2001
From: Helianthella <git@gumi.ca>
Date: Tue, 22 Dec 2020 10:22:57 -0500
Subject: fix registration and account recovery
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On Vue 3, ref names and v-model names are both assigned to the scope of the component,
unlike in Vue 2, where refs were only registered on vm.$refs. This means if you
have a <input v-model="blah" ref="blah"> the ref will override the model and thus
the model will not work. This is, of course, undocumented in the migration guide 🙄
---
 src/views/Registration.vue | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

(limited to 'src/views/Registration.vue')

diff --git a/src/views/Registration.vue b/src/views/Registration.vue
index 214288b..e220dc2 100644
--- a/src/views/Registration.vue
+++ b/src/views/Registration.vue
@@ -57,7 +57,7 @@
 			If you did not provide an email address you will be unable to perform password resets.</p>
 			<form @submit.prevent="checkEmail">
 				<label for="email">Enter your email (optional):</label>
-				<input v-model="user.email" type="email" maxlength="39" id="email" ref="email" placeholder="your@email.com">
+				<input v-model="user.email" type="email" maxlength="39" id="email" ref="_email" placeholder="your@email.com">
 				<button type="submit">Next step &rarr;</button>
 			</form>
 		</div>
@@ -74,7 +74,7 @@
 
 			<form @submit.prevent="checkUser">
 				<label for="user">Choose a username:</label>
-				<input @input="taken = false" v-model="user.name" type="text" id="user" ref="user" placeholder="type your username here" minlength="4" maxlength="23" pattern="^[a-zA-Z0-9]{4,23}$" title="4-23 characters, alphanumeric" required>
+				<input @input="taken = false" v-model="user.name" type="text" id="user" ref="_user" placeholder="type your username here" minlength="4" maxlength="23" pattern="^[a-zA-Z0-9]{4,23}$" title="4-23 characters, alphanumeric" required>
 				<button type="submit" v-if="user.name">Next step &rarr;</button>
 			</form>
 		</div>
@@ -93,12 +93,12 @@
 			<form @submit.prevent="checkPassword">
 				<div class="pass-box">
 					<label for="password">Choose a unique password:</label>
-					<input v-model="user.pwd" :type="visible ? 'text' : 'password'" id="password" ref="password" placeholder="type your password here" minlength="8" maxlength="23" pattern="^[a-zA-Z0-9]{8,23}$" title="8-23 characters, alphanumeric" required>
+					<input v-model="user.pwd" :type="visible ? 'text' : 'password'" id="password" ref="_password" placeholder="type your password here" minlength="8" maxlength="23" pattern="^[a-zA-Z0-9]{8,23}$" title="8-23 characters, alphanumeric" required>
 					<span @click="visible = !visible"></span>
 				</div>
 				<div class="pass-box">
 					<label for="password2">Confirm your password:</label>
-					<input v-model="user.pwd2" :type="visible ? 'text' : 'password'" id="password2" ref="password2" placeholder="type your password again" minlength="8" maxlength="23" pattern="^[a-zA-Z0-9]{8,23}$" title="8-23 characters, alphanumeric" required>
+					<input v-model="user.pwd2" :type="visible ? 'text' : 'password'" id="password2" ref="_password2" placeholder="type your password again" minlength="8" maxlength="23" pattern="^[a-zA-Z0-9]{8,23}$" title="8-23 characters, alphanumeric" required>
 					<span @click="visible = !visible"></span>
 				</div>
 				<button type="submit" v-if="user.pwd && user.pwd === user.pwd2">Next step &rarr;</button>
@@ -181,7 +181,7 @@ export default class Registration extends Vue {
 			await reCAPTCHA.load();
 			this.step = 1;
 			await this.$nextTick();
-			(this.$refs.email as HTMLInputElement).focus();
+			(this.$refs._email as HTMLInputElement).focus();
 		} catch (err) {
 			this.step = -1
 		}
@@ -190,14 +190,14 @@ export default class Registration extends Vue {
 	async checkEmail () {
 		this.step = 2;
 		await this.$nextTick();
-		(this.$refs.user as HTMLInputElement).focus();
+		(this.$refs._user as HTMLInputElement).focus();
 	}
 
 	async checkUser () {
 		// TODO: check here whether the username is taken
 		this.step = 3;
 		await this.$nextTick();
-		(this.$refs.password as HTMLInputElement).focus();
+		(this.$refs._password as HTMLInputElement).focus();
 	}
 
 	// TODO: this is not compatible with Edge! we must polyfill
@@ -245,7 +245,7 @@ export default class Registration extends Vue {
 
 			this.exposed = true;
 			await this.$nextTick();
-			(this.$refs.password as HTMLInputElement).focus();
+			(this.$refs._password as HTMLInputElement).focus();
 		} else {
 			this.exposed = false;
 			this.step = 4;
@@ -303,7 +303,7 @@ export default class Registration extends Vue {
 				this.taken = true;
 				this.step = 2;
 				await this.$nextTick();
-				(this.$refs.user as HTMLInputElement).focus();
+				(this.$refs._user as HTMLInputElement).focus();
 				break;
 			case 429:
 				self.alert("Too many requests.\nPlease try again later");
-- 
cgit v1.2.3-70-g09d2

