From b1c5800a8dcd8e845d3d9192638b94bf7c25a1d0 Mon Sep 17 00:00:00 2001 From: supertiger1234 Date: Mon, 2 Mar 2020 11:39:46 +0000 Subject: [PATCH] added suspend reason --- public/index.html | 12 ++-- .../app/Popouts/Popouts/AddServer.vue | 10 ++- .../Popouts/Popouts/ServerInvitePopout.vue | 22 ++++++- .../Popouts/Popouts/adminManageUserPopout.vue | 17 ++++-- .../Popouts/Popouts/userInformationPopout.vue | 6 +- .../app/Tabs/AdminPanel/UserTemplate.vue | 15 ++++- src/services/AuthenticationService.js | 17 ++++-- src/services/adminService.js | 6 +- src/views/LoginPage.vue | 58 ++++++++++++++++-- src/views/RegisterPage.vue | 61 +++++++++++++++---- 10 files changed, 182 insertions(+), 42 deletions(-) diff --git a/public/index.html b/public/index.html index 60f6ebf..f9138c0 100644 --- a/public/index.html +++ b/public/index.html @@ -61,12 +61,12 @@ diff --git a/src/components/app/Popouts/Popouts/AddServer.vue b/src/components/app/Popouts/Popouts/AddServer.vue index c63921b..2741bb8 100644 --- a/src/components/app/Popouts/Popouts/AddServer.vue +++ b/src/components/app/Popouts/Popouts/AddServer.vue @@ -180,9 +180,13 @@ export default { } event.target.classList.add("button-clicked"); - const { ok, error, result } = await ServerService.getInviteDetail( - inviteCode - ); + let code; + if (inviteCode.split("/").length >= 2) { + code = inviteCode.split("/").pop(); + } else { + code = inviteCode; + } + const { ok, error, result } = await ServerService.getInviteDetail(code); if (!ok) { event.target.classList.remove("button-clicked"); diff --git a/src/components/app/Popouts/Popouts/ServerInvitePopout.vue b/src/components/app/Popouts/Popouts/ServerInvitePopout.vue index 96c440b..dc87ccb 100644 --- a/src/components/app/Popouts/Popouts/ServerInvitePopout.vue +++ b/src/components/app/Popouts/Popouts/ServerInvitePopout.vue @@ -20,7 +20,8 @@ :key="invite" class="invite" > - {{ invite }} + https://nertivia.tk/invites/{{ invite }} +
Copy
@@ -71,6 +72,9 @@ export default { if (ok) { this.invites.push(result.data.invite_code); } + }, + copy(invite) { + this.$clipboard("https://nertivia.tk/invites/" + invite); } }, computed: { @@ -154,4 +158,20 @@ export default { margin-right: 0; padding: 10px; } +.link { + color: rgba(255, 255, 255, 0.5); +} + +.copy-button { + display: flex; + margin: auto; + margin-right: 0; + flex-shrink: 0; + cursor: pointer; + opacity: 0.7; + transition: 0.2s; +} +.copy-button:hover { + opacity: 1; +} diff --git a/src/components/app/Popouts/Popouts/adminManageUserPopout.vue b/src/components/app/Popouts/Popouts/adminManageUserPopout.vue index c3f494d..b563d26 100644 --- a/src/components/app/Popouts/Popouts/adminManageUserPopout.vue +++ b/src/components/app/Popouts/Popouts/adminManageUserPopout.vue @@ -1,12 +1,16 @@ @@ -41,7 +43,7 @@ export default { this.$store.dispatch("setAllPopout", { show: true, type: "ADMIN_MANAGE_USER", - uniqueID: this.user.uniqueID + user: this.user }); } } @@ -61,6 +63,12 @@ export default { background: rgba(0, 0, 0, 0.2); } } +.suspended { + background: rgb(255, 45, 45); + border-radius: 4px; + padding: 3px; + display: flex; +} .profile-picture { width: 40px; height: 40px; @@ -72,6 +80,11 @@ export default { background-size: cover; background-repeat: no-repeat; } +.details { + display: flex; + flex-direction: column; + align-items: flex-start; +} .date { font-size: 14px; opacity: 0.6; diff --git a/src/services/AuthenticationService.js b/src/services/AuthenticationService.js index 6a6800b..84fd373 100644 --- a/src/services/AuthenticationService.js +++ b/src/services/AuthenticationService.js @@ -1,21 +1,26 @@ import { instance, wrapper } from "./Api"; -const config = require('../config.js'); +const config = require("../config.js"); let domain = ""; -if (config.serverURL) domain = config.serverURL+"/" +if (config.serverURL) domain = config.serverURL + "/"; export default { register(credentials) { - return wrapper(instance().post(domain+"user/register", credentials)); + return wrapper(instance().post(domain + "user/register", credentials)); + }, + confirmEmail(email, code) { + return wrapper( + instance().post(domain + "user/register/confirm", { email, code }) + ); }, login(credentials) { - return wrapper(instance().post(domain+"user/login", credentials)); + return wrapper(instance().post(domain + "user/login", credentials)); }, logout() { - return wrapper(instance().delete(domain+"user/logout")); + return wrapper(instance().delete(domain + "user/logout")); }, user() { - return wrapper(instance().get(domain+"user")); + return wrapper(instance().get(domain + "user")); } }; diff --git a/src/services/adminService.js b/src/services/adminService.js index bb082c0..d6d4ef5 100644 --- a/src/services/adminService.js +++ b/src/services/adminService.js @@ -19,9 +19,11 @@ export default { approveTheme(id) { return wrapper(instance().patch(`admin/themes/${id}/approve`)); }, - suspendUser(uniqueID, password) { + suspendUser(uniqueID, password, reason) { return wrapper( - instance().delete(`admin/users/${uniqueID}`, { data: { password } }) + instance().delete(`admin/users/${uniqueID}`, { + data: { password, reason } + }) ); } }; diff --git a/src/views/LoginPage.vue b/src/views/LoginPage.vue index bb2bfb6..ac24fc7 100644 --- a/src/views/LoginPage.vue +++ b/src/views/LoginPage.vue @@ -12,7 +12,7 @@
Login to access Nertivia
-
+
Beep Boop @@ -75,6 +75,23 @@
+
+
+
+ Check your email: + - {{ confirm_code.alert }} +
+ +
+
@@ -96,10 +113,11 @@ export default { return { isElectron: window && window.process && window.process.type, - showCaptcha: false, + currentPage: 0, visible: true, email: { value: "", alert: "" }, password: { value: "", alert: "" }, + confirm_code: { value: "", alert: "" }, reCaptcha: { alert: "" }, otherError: "", @@ -121,7 +139,7 @@ export default { this.login(); }, submitForm() { - this.showCaptcha = true; + this.currentPage = 1; }, keyDownEvent(event) { if (event.keyCode === 13) { @@ -155,7 +173,7 @@ export default { window.location.href = "/app"; }, 1000); } else { - this.showCaptcha = false; + this.currentPage = 0; this.deactive = false; this.captchaToken = null; this.$refs.recaptcha.resetRecaptcha(); @@ -163,6 +181,10 @@ export default { this.otherError = "Can't connect to server."; return; } + if (error.response.data.code === "CONFIRM_EMAIL") { + this.currentPage = 2; + return; + } const errors = error.response.data.errors; for (let index in errors) { const message = errors[index].msg; @@ -177,6 +199,29 @@ export default { }, registerButton() { this.$router.push("/register"); + }, + async confirmCodeInput(event) { + const value = event.target.value; + if (value.length === 10) { + const { ok, result, error } = await AuthenticationService.confirmEmail( + this.email.value, + value + ); + if (!ok) { + if (error.response === undefined) { + this.otherError = "Can't connect to server."; + return; + } + this.confirm_code.alert = + error.response.data.error || "Something went wrong."; + } else { + this.visible = false; + this.$store.dispatch("token", result.data.token); + setTimeout(() => { + window.location.href = "/app"; + }, 1000); + } + } } } }; @@ -268,7 +313,8 @@ body { text-align: center; margin-bottom: 10px; } -form { +form, +.form { display: flex; flex-direction: column; width: 100%; diff --git a/src/views/RegisterPage.vue b/src/views/RegisterPage.vue index cd6698a..db9f09a 100644 --- a/src/views/RegisterPage.vue +++ b/src/views/RegisterPage.vue @@ -14,7 +14,7 @@ Welcome, new user! I Hope you enjoy Nertivia!
-
+
Beep Boop
@@ -92,6 +92,23 @@
+
+
+
+ Check your email: + - {{ confirm_code.alert }} +
+ +
+
@@ -113,8 +130,9 @@ export default { return { isElectron: window && window.process && window.process.type, - showCaptcha: false, + currentPage: 0, visible: true, + confirm_code: { value: "", alert: "" }, email: { value: "", alert: "" }, username: { value: "", alert: "" }, password: { value: "", alert: "" }, @@ -137,7 +155,7 @@ export default { this.register(); }, formSubmit() { - this.showCaptcha = true; + this.currentPage = 1; }, keyDownEvent(event) { if (event.keyCode === 13) { @@ -151,20 +169,16 @@ export default { const username = this.username.value.trim(); const password = this.password.value.trim(); - const { ok, error, result } = await AuthenticationService.register({ + const { ok, error } = await AuthenticationService.register({ email, username, password, token: this.captchaToken }); if (ok) { - this.visible = false; - this.$store.dispatch("token", result.data.token); - setTimeout(() => { - window.location.href = "/app"; - }, 1000); + this.currentPage = 2; } else { - this.showCaptcha = false; + this.currentPage = 0; this.deactive = false; this.captchaToken = null; this.$refs.recaptcha.resetRecaptcha(); @@ -186,6 +200,29 @@ export default { }, loginButton() { this.$router.push("/login"); + }, + async confirmCodeInput(event) { + const value = event.target.value; + if (value.length === 10) { + const { ok, result, error } = await AuthenticationService.confirmEmail( + this.email.value, + value + ); + if (!ok) { + if (error.response === undefined) { + this.otherError = "Can't connect to server."; + return; + } + this.confirm_code.alert = + error.response.data.error || "Something went wrong."; + } else { + this.visible = false; + this.$store.dispatch("token", result.data.token); + setTimeout(() => { + window.location.href = "/app"; + }, 1000); + } + } } } }; @@ -276,7 +313,7 @@ body { text-align: center; margin-bottom: 10px; } -form { +form, .form { display: flex; flex-direction: column; width: 100%;