X-Git-Url: https://git.auder.net/assets/current/gitweb.js?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FUpsertUser.vue;h=2be637c678d0c52331779dcde795f4d40587ca32;hb=efdfb4c70f4a4391b8571726d924cdf58baba41c;hp=222a8625a166c35e27258d907ad63c8d53c4e5a6;hpb=6808d7a16ec1e761c6a2dffec2281c96953e4d89;p=vchess.git diff --git a/client/src/components/UpsertUser.vue b/client/src/components/UpsertUser.vue index 222a8625..2be637c6 100644 --- a/client/src/components/UpsertUser.vue +++ b/client/src/components/UpsertUser.vue @@ -1,31 +1,56 @@ @@ -42,17 +67,18 @@ export default { logStage: "Login", //or Register infoMsg: "", enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy - st: store.state + st: store.state, + user: {} }; }, watch: { nameOrEmail: function(newValue) { if (newValue.indexOf("@") >= 0) { - this.st.user.email = newValue; - this.st.user.name = ""; + this.user.email = newValue; + this.user.name = ""; } else { - this.st.user.name = newValue; - this.st.user.email = ""; + this.user.name = newValue; + this.user.email = ""; } } }, @@ -77,6 +103,12 @@ export default { if (event.target.checked) { this.infoMsg = ""; this.enterTime = Date.now(); + document.getElementById("u_username").focus(); + this.user = { + name: this.st.user.name, + email: this.st.user.email, + notify: this.st.user.notify + }; } }, toggleStage: function() { @@ -110,7 +142,7 @@ export default { case "Login": return "Connection token sent. Check your emails!"; case "Register": - return "Registration complete! Please check your emails"; + return "Registration complete! Please check your emails now"; case "Update": return "Modifications applied!"; } @@ -124,9 +156,9 @@ export default { if (this.stage == "Login") { const type = this.nameOrEmail.indexOf("@") >= 0 ? "email" : "name"; error = checkNameEmail({ [type]: this.nameOrEmail }); - } else error = checkNameEmail(this.st.user); + } else error = checkNameEmail(this.user); if (error) { - alert(error); + alert(this.st.tr[error]); return; } this.infoMsg = "Processing... Please wait"; @@ -135,10 +167,15 @@ export default { this.ajaxMethod(), this.stage == "Login" ? { nameOrEmail: this.nameOrEmail } - : this.st.user, + : this.user, () => { this.infoMsg = this.infoMessage(); if (this.stage != "Update") this.nameOrEmail = ""; + else { + this.st.user.name = this.user.name; + this.st.user.email = this.user.email; + this.st.user.notify = this.user.notify; + } }, err => { this.infoMsg = ""; @@ -156,8 +193,9 @@ export default {