From 32fc540df4a77076e3365e5471e13ea45a04c508 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Wed, 18 Oct 2023 03:21:06 +0200 Subject: [PATCH] upd: handle email signups properly with approval enabled --- packages/backend/src/server/api/SignupApiService.ts | 10 +++++++--- packages/frontend/src/pages/admin-user.vue | 2 +- packages/frontend/src/pages/signup-complete.vue | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 53f770e172..418656fdbc 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -277,10 +277,14 @@ export class SignupApiService { pendingUserId: null, }); } - + if (instance.approvalRequiredForSignup) { - reply.code(204); - return; + if (pendingUser.email) { + this.emailService.sendEmail(pendingUser.email, 'Approval pending', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.', + 'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.'); + } + return { pendingApproval: true }; } return this.signinService.signin(request, reply, account as MiLocalUser); diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index 47b4b1b14d..4643ac6e7e 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -182,7 +182,7 @@ SPDX-License-Identifier: AGPL-3.0-only
- + diff --git a/packages/frontend/src/pages/signup-complete.vue b/packages/frontend/src/pages/signup-complete.vue index 4ebd0e15b3..3b1e5468f7 100644 --- a/packages/frontend/src/pages/signup-complete.vue +++ b/packages/frontend/src/pages/signup-complete.vue @@ -45,6 +45,13 @@ function submit() { os.api('signup-pending', { code: props.code, }).then(res => { + if (res.pendingApproval) { + return os.alert({ + type: 'success', + title: i18n.ts._signup.almostThere, + text: i18n.ts._signup.approvalPending, + }); + } return login(res.i, '/'); }).catch(() => { submitting = false;