From c850c8e64a34cf7fcee584e6a20a2b801830a74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20M=C3=A9doc?= Date: Thu, 1 Aug 2024 19:40:52 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=8A=20Any=20length=20of=20invi?= =?UTF-8?q?tation=20code=20(#469)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizarr_backend/app/models/wizarr/invitations.py | 6 +++--- .../src/modules/admin/components/Forms/InvitationForm.vue | 5 ++--- apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/wizarr-backend/wizarr_backend/app/models/wizarr/invitations.py b/apps/wizarr-backend/wizarr_backend/app/models/wizarr/invitations.py index 955fb8b9..18f132c8 100644 --- a/apps/wizarr-backend/wizarr_backend/app/models/wizarr/invitations.py +++ b/apps/wizarr-backend/wizarr_backend/app/models/wizarr/invitations.py @@ -51,8 +51,8 @@ def validate_code(self, _, value: str): if value is None: return - # Check that the code is a 6 character string of only letters and numbers - if not isinstance(value, str) or len(value) != 6 or not value.isalnum(): + # Check that the code only contains letters and numbers + if not isinstance(value, str) or not value.isalnum(): raise ValidationError("Invalid code") # Check that the code has not been used @@ -104,7 +104,7 @@ def create_code(): raise ValidationError("Unable to generate a unique code") # If code is None, generate a new code - if not invitation["code"] or len(invitation["code"]) != 6 or not str(invitation["code"]).isalnum(): + if not invitation["code"] or not str(invitation["code"]).isalnum(): invitation["code"] = create_code() # Upper case the code diff --git a/apps/wizarr-frontend/src/modules/admin/components/Forms/InvitationForm.vue b/apps/wizarr-frontend/src/modules/admin/components/Forms/InvitationForm.vue index 97eaaac3..211e1dcf 100644 --- a/apps/wizarr-frontend/src/modules/admin/components/Forms/InvitationForm.vue +++ b/apps/wizarr-frontend/src/modules/admin/components/Forms/InvitationForm.vue @@ -5,7 +5,7 @@
- + @@ -399,8 +399,7 @@ export default defineComponent({ watch: { "invitationData.inviteCode": { immediate: true, - handler(inviteCode) { - if (inviteCode.length >= 7) this.invitationData.inviteCode = inviteCode.slice(0, 6); + handler() { this.invitationData.inviteCode = this.invitationData.inviteCode.replace(/[^a-zA-Z0-9]/g, ""); this.invitationData.inviteCode = this.invitationData.inviteCode.toUpperCase(); }, diff --git a/apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue b/apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue index 0ea3933d..e5ae35c0 100644 --- a/apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue +++ b/apps/wizarr-frontend/src/modules/home/pages/JoinForm.vue @@ -30,8 +30,8 @@ export default defineComponent({ methods: { async join() { // Check if the code is inputted - if (!this.code || this.code.length !== 6) { - this.$toast.info(this.__('Please enter an invite code')); + if (!this.code) { + this.$toast.info(this.__("Please enter an invite code")); return; }