Browse Source

feat(AccountRemoval): added github_redirect to modal after relinking github

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 3 years ago
parent
commit
5a762270bb

+ 12 - 4
frontend/src/components/modals/RemoveAccount.vue

@@ -130,6 +130,7 @@
 				<div class="content-box-inputs">
 					<a
 						class="button is-github"
+						@click="relinkGithub()"
 						:href="`${apiDomain}/auth/github/link`"
 					>
 						<div class="icon">
@@ -182,6 +183,7 @@ export default {
 	components: { Modal, Confirm },
 	data() {
 		return {
+			name: "RemoveAccount",
 			step: "confirm-identity",
 			apiDomain: "",
 			password: {
@@ -227,14 +229,20 @@ export default {
 							`Your GitHub account isn't linked. Please re-link your account and try again.`
 						);
 						this.step = "relink-github";
-						localStorage.setItem(
-							"github_redirect",
-							window.location.pathname + window.location.search
-						);
 					}
 				} else new Toast(res.message);
 			});
 		},
+		relinkGithub() {
+			localStorage.setItem(
+				"github_redirect",
+				`${window.location.pathname + window.location.search}${
+					!this.$route.query.removeAccount
+						? "&removeAccount=relinked-github"
+						: ""
+				}`
+			);
+		},
 		remove() {
 			return this.socket.dispatch("users.remove", res => {
 				if (res.status === "success") {

+ 16 - 0
frontend/src/pages/Settings/tabs/Account.vue

@@ -171,6 +171,22 @@ export default {
 			}
 		}
 	},
+	mounted() {
+		if (
+			this.$route.query.removeAccount === "relinked-github" &&
+			!localStorage.getItem("github_redirect")
+		) {
+			this.openModal("removeAccount");
+
+			setTimeout(() => {
+				const modal = this.$parent.$children.find(
+					child => child.name === "RemoveAccount"
+				);
+
+				modal.confirmGithubLink();
+			}, 50);
+		}
+	},
 	methods: {
 		onInput(inputName) {
 			this.validation[inputName].entered = true;