mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 16:51:15 +10:00
* fix: server side validation and client side validation for invitation creation * fix: lint
This commit is contained in:
@ -1,18 +1,14 @@
|
||||
import { type } from "arktype";
|
||||
import { readDropValidatedBody, throwingArktype } from "~/server/arktype";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
import { CreateUserValidator } from "../../../auth/signup/simple.post";
|
||||
|
||||
const CreateInvite = type({
|
||||
isAdmin: "boolean?",
|
||||
username: "string?",
|
||||
email: "string.email?",
|
||||
expires: "string.date.iso.parse",
|
||||
const CreateInvite = CreateUserValidator.and({
|
||||
expires: "Date",
|
||||
isAdmin: "boolean = false",
|
||||
}).configure(throwingArktype);
|
||||
|
||||
export default defineEventHandler<{
|
||||
body: typeof CreateInvite.infer;
|
||||
}>(async (h3) => {
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, [
|
||||
"auth:simple:invitation:new",
|
||||
]);
|
||||
@ -20,6 +16,8 @@ export default defineEventHandler<{
|
||||
|
||||
const body = await readDropValidatedBody(h3, CreateInvite);
|
||||
|
||||
console.log(body);
|
||||
|
||||
const invitation = await prisma.invitation.create({
|
||||
data: body,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user