diff --git a/src/actions/signup.ts b/src/actions/signup.ts index 3db2a45..98854e0 100644 --- a/src/actions/signup.ts +++ b/src/actions/signup.ts @@ -66,6 +66,17 @@ export const signup = { }); } + // check if user is blocked + if (uuid) { + const blockedUser = await db.getBlockedUserByUuid({ uuid: uuid }); + if (blockedUser) { + throw new ActionError({ + code: 'FORBIDDEN', + message: 'Du bist für die Registrierung gesperrt' + }); + } + } + if (!teamDraft) { // check if a team with the same name already exists if (input.teamName) { diff --git a/src/actions/user.ts b/src/actions/user.ts index ca256a7..a91eab6 100644 --- a/src/actions/user.ts +++ b/src/actions/user.ts @@ -84,5 +84,41 @@ export const user = { users: users }; } + }), + addBlocked: defineAction({ + input: z.object({ + uuid: z.string(), + comment: z.string().nullable() + }), + handler: async (input, context) => { + Session.actionSessionFromCookies(context.cookies, Permissions.Users); + + const { id } = await db.addBlockedUser(input); + + return { + id: id + }; + } + }), + editBlocked: defineAction({ + input: z.object({ + id: z.number(), + uuid: z.string(), + comment: z.string().nullable() + }), + handler: async (input, context) => { + Session.actionSessionFromCookies(context.cookies, Permissions.Users); + + await db.editBlockedUser(input); + } + }), + blocked: defineAction({ + handler: async (_, context) => { + Session.actionSessionFromCookies(context.cookies, Permissions.Users); + + return { + blocked: await db.getBlockedUsers({}) + }; + } }) }; diff --git a/src/app/admin/usersBlocked/CreateOrEditPopup.svelte b/src/app/admin/usersBlocked/CreateOrEditPopup.svelte new file mode 100644 index 0000000..e1432f6 --- /dev/null +++ b/src/app/admin/usersBlocked/CreateOrEditPopup.svelte @@ -0,0 +1,101 @@ + + + +