Prechádzať zdrojové kódy

refactor: Remove recaptcha

Owen Diffey 2 týždňov pred
rodič
commit
8b0d302b04

+ 0 - 3
.wiki/Configuration.md

@@ -89,9 +89,6 @@ For more information on configuration files please refer to the
 | `apis.soundcloud.rateLimit` | Minimum interval between SoundCloud API requests in milliseconds. |
 | `apis.soundcloud.requestTimeout` | SoundCloud API requests timeout in milliseconds. |
 | `apis.soundcloud.retryAmount` | The amount of retries to perform of a failed SoundCloud API request. |
-| `apis.recaptcha.enabled` | Whether to enable ReCaptcha in the regular (email) registration form. |
-| `apis.recaptcha.key` | ReCaptcha Site v3 key, obtained from [here](https://www.google.com/recaptcha/admin). |
-| `apis.recaptcha.secret` | ReCaptcha Site v3 secret, obtained with key. |
 | `apis.github.enabled` | Whether to enable GitHub authentication. |
 | `apis.github.client` | GitHub OAuth Application client, obtained from [here](https://github.com/settings/developers). |
 | `apis.github.secret` | GitHub OAuth Application secret, obtained with client. |

+ 0 - 5
backend/config/default.json

@@ -47,11 +47,6 @@
 			"requestTimeout": 5000,
 			"retryAmount": 2
 		},
-		"recaptcha": {
-			"enabled": false,
-			"key": "",
-			"secret": ""
-		},
 		"github": {
 			"enabled": false,
 			"client": "",

+ 0 - 4
backend/src/modules/WebSocketModule.ts

@@ -177,10 +177,6 @@ export class WebSocketModule extends BaseModule {
 			config: {
 				cookie: config.get("cookie"),
 				sitename: config.get("sitename"),
-				recaptcha: {
-					enabled: config.get("apis.recaptcha.enabled"),
-					key: config.get("apis.recaptcha.key")
-				},
 				githubAuthentication: config.get("apis.github.enabled"),
 				messages: config.get("messages"),
 				christmas: config.get("christmas"),

+ 0 - 1
frontend/.eslintrc

@@ -26,7 +26,6 @@
 		"@typescript-eslint"
 	],
 	"globals": {
-		"grecaptcha": "readonly",
 		"history": "readonly"
 	},
 	"rules": {

+ 0 - 33
frontend/src/components/modals/Register.vue

@@ -35,7 +35,6 @@ const password = ref({
 	message:
 		"Include at least one lowercase letter, one uppercase letter, one number and one special character."
 });
-const recaptchaToken = ref("");
 const passwordElement = ref();
 
 const { register } = useUserAuthStore();
@@ -53,7 +52,6 @@ const submitModal = () => {
 		username: username.value.value,
 		email: email.value.value,
 		password: password.value.value,
-		recaptchaToken: recaptchaToken.value
 	})
 		.then((res: any) => {
 			if (res.status === "success") window.location.reload();
@@ -146,27 +144,6 @@ onMounted(async () => {
 		new Toast("Registration is disabled.");
 		closeCurrentModal();
 	}
-
-	if (recaptcha.value.enabled) {
-		const recaptchaScript = document.createElement("script");
-		recaptchaScript.onload = () => {
-			grecaptcha.ready(() => {
-				grecaptcha
-					.execute(recaptcha.value.key, {
-						action: "login"
-					})
-					.then(token => {
-						recaptchaToken.value = token;
-					});
-			});
-		};
-
-		recaptchaScript.setAttribute(
-			"src",
-			`https://www.google.com/recaptcha/api.js?render=${recaptcha.value.key}`
-		);
-		document.head.appendChild(recaptchaScript);
-	}
 });
 </script>
 
@@ -342,17 +319,7 @@ onMounted(async () => {
 	filter: brightness(5);
 }
 
-#recaptcha {
-	padding: 10px 0;
-}
-
 a {
 	color: var(--primary-color);
 }
 </style>
-
-<style lang="less">
-.grecaptcha-badge {
-	z-index: 2000;
-}
-</style>

+ 0 - 8
frontend/src/stores/config.ts

@@ -4,10 +4,6 @@ export const useConfigStore = defineStore("config", {
 	state: (): {
 		cookie: string;
 		sitename: string;
-		recaptcha: {
-			enabled: boolean;
-			key: string;
-		};
 		githubAuthentication: boolean;
 		messages: Record<string, string>;
 		christmas: boolean;
@@ -28,10 +24,6 @@ export const useConfigStore = defineStore("config", {
 	} => ({
 		cookie: "musareSID",
 		sitename: MUSARE_SITENAME,
-		recaptcha: {
-			enabled: false,
-			key: ""
-		},
 		githubAuthentication: false,
 		messages: {
 			accountRemoval:

+ 0 - 5
frontend/src/stores/modals.ts

@@ -35,11 +35,6 @@ export const useModalsStore = defineStore("modals", {
 		closeModal(uuid: string, force = false) {
 			Object.entries(this.modals).forEach(([_uuid, modal]) => {
 				if (uuid === _uuid) {
-					if (modal.modal === "register") {
-						const configStore = useConfigStore();
-						if (configStore.recaptcha.enabled)
-							window.location.reload();
-					}
 					const close = () => {
 						const { socket } = useWebsocketsStore();
 						socket.destroyModalListeners(uuid);

+ 2 - 4
frontend/src/stores/userAuth.ts

@@ -40,9 +40,8 @@ export const useUserAuthStore = defineStore("userAuth", () => {
 		username: string;
 		email: string;
 		password: string;
-		recaptchaToken: string;
 	}) => {
-		const { username, email, password, recaptchaToken } = user;
+		const { username, email, password } = user;
 
 		if (!email || !username || !password)
 			throw new Error("Please fill in all fields");
@@ -80,8 +79,7 @@ export const useUserAuthStore = defineStore("userAuth", () => {
 		const data = await websocketStore.runJob("users.register", {
 			username,
 			email,
-			password,
-			recaptchaToken
+			password
 		});
 
 		if (!data?.SID) throw new Error("You must login");

+ 0 - 1
frontend/src/types/global.d.ts

@@ -5,7 +5,6 @@ declare global {
 	var stationInterval: number;
 	var YT: any;
 	var stationNextSongTimeout: any;
-	var grecaptcha: any;
 	var addToPlaylistDropdown: any;
 	var scrollDebounceId: any;
 	var focusedElementBefore: any;