mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
[user] username change - fix error message if too short
This commit is contained in:
parent
05c34df83d
commit
8d01ba375a
@ -42,7 +42,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form @submit.prevent="changeUsername" :disabled="saving">
|
<form @submit.prevent="changeUsername" :disabled="savingUsername">
|
||||||
<h3 class="h6"><T>user.account.changeUsername.header</T></h3>
|
<h3 class="h6"><T>user.account.changeUsername.header</T></h3>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" class="form-control" v-model="username"
|
<input type="text" class="form-control" v-model="username"
|
||||||
@ -53,7 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form @submit.prevent="changeEmail" :disabled="saving">
|
<form @submit.prevent="changeEmail" :disabled="savingEmail">
|
||||||
<h3 class="h6"><T>user.account.changeEmail.header</T></h3>
|
<h3 class="h6"><T>user.account.changeEmail.header</T></h3>
|
||||||
<div v-if="!changeEmailAuthId" class="input-group mb-3">
|
<div v-if="!changeEmailAuthId" class="input-group mb-3">
|
||||||
<input type="email" class="form-control" v-model="email" required/>
|
<input type="email" class="form-control" v-model="email" required/>
|
||||||
@ -136,7 +136,8 @@
|
|||||||
socialProviders,
|
socialProviders,
|
||||||
socialConnections: undefined,
|
socialConnections: undefined,
|
||||||
|
|
||||||
saving: false,
|
savingUsername: false,
|
||||||
|
savingEmail: false,
|
||||||
|
|
||||||
gravatar,
|
gravatar,
|
||||||
}
|
}
|
||||||
@ -157,12 +158,12 @@
|
|||||||
async changeUsername() {
|
async changeUsername() {
|
||||||
this.error = '';
|
this.error = '';
|
||||||
|
|
||||||
if (this.saving) { return; }
|
if (this.savingUsername) { return; }
|
||||||
this.saving = true;
|
this.savingUsername = true;
|
||||||
const response = await this.$axios.$post(`/user/change-username`, {
|
const response = await this.$axios.$post(`/user/change-username`, {
|
||||||
username: this.username,
|
username: this.username,
|
||||||
});
|
});
|
||||||
this.saving = false;
|
this.savingUsername = false;
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
this.error = response.error;
|
this.error = response.error;
|
||||||
@ -178,14 +179,14 @@
|
|||||||
async changeEmail() {
|
async changeEmail() {
|
||||||
this.error = '';
|
this.error = '';
|
||||||
|
|
||||||
if (this.saving) { return; }
|
if (this.savingEmail) { return; }
|
||||||
this.saving = true;
|
this.savingEmail = true;
|
||||||
const response = await this.$axios.$post(`/user/change-email`, {
|
const response = await this.$axios.$post(`/user/change-email`, {
|
||||||
email: this.email,
|
email: this.email,
|
||||||
authId: this.changeEmailAuthId,
|
authId: this.changeEmailAuthId,
|
||||||
code: this.code,
|
code: this.code,
|
||||||
});
|
});
|
||||||
this.saving = false;
|
this.savingEmail = false;
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
this.error = response.error;
|
this.error = response.error;
|
||||||
|
@ -259,7 +259,7 @@ router.post('/user/change-username', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req.body.username.length < 4 || req.body.username.length > 16 || !req.body.username.match(new RegExp(`^[${USERNAME_CHARS}]+$`))) {
|
if (req.body.username.length < 4 || req.body.username.length > 16 || !req.body.username.match(new RegExp(`^[${USERNAME_CHARS}]+$`))) {
|
||||||
return { error: 'user.account.changeUsername.invalid' }
|
return res.json({ error: 'user.account.changeUsername.invalid' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbUser = await req.db.get(SQL`SELECT * FROM users WHERE lower(trim(replace(replace(replace(replace(replace(replace(replace(replace(replace(username, 'Ą', 'ą'), 'Ć', 'ć'), 'Ę', 'ę'), 'Ł', 'ł'), 'Ń', 'ń'), 'Ó', 'ó'), 'Ś', 'ś'), 'Ż', 'ż'), 'Ź', 'ż'))) = ${normalise(req.body.username)}`);
|
const dbUser = await req.db.get(SQL`SELECT * FROM users WHERE lower(trim(replace(replace(replace(replace(replace(replace(replace(replace(replace(username, 'Ą', 'ą'), 'Ć', 'ć'), 'Ę', 'ę'), 'Ł', 'ł'), 'Ń', 'ń'), 'Ó', 'ó'), 'Ś', 'ś'), 'Ż', 'ż'), 'Ź', 'ż'))) = ${normalise(req.body.username)}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user