Kundendatenmodule - Daten speichern wenn nicht eingeloggt
This commit is contained in:
@@ -38,7 +38,7 @@ export const POST = defineApiRoute({
|
||||
if (input.telefon) updateData.telefon = input.telefon;
|
||||
if (input.verified) updateData.telefon = input.verified;
|
||||
|
||||
//Admin may update other users
|
||||
//Only Admin can update other users
|
||||
if (user.rolle == Enums.BenutzerRolle.ADMIN && input.id != user.id) {
|
||||
updateData.id = input.id;
|
||||
} else if(user.rolle != Enums.BenutzerRolle.ADMIN && input.id != user.id){
|
||||
@@ -64,9 +64,14 @@ export const GET = defineApiRoute({
|
||||
email: z.string()
|
||||
})),
|
||||
output: z.array(BenutzerSchema),
|
||||
middleware: adminMiddleware,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, admin) {
|
||||
if ("id" in input) {
|
||||
//Only Admin can read other users
|
||||
if (admin.rolle != Enums.BenutzerRolle.ADMIN && input.id != admin.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await prisma.benutzer.findUnique({
|
||||
where: {
|
||||
id: input.id
|
||||
@@ -79,6 +84,11 @@ export const GET = defineApiRoute({
|
||||
|
||||
return [user];
|
||||
} else {
|
||||
//Only admin can read many users
|
||||
if (admin.rolle != Enums.BenutzerRolle.ADMIN ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const users = await prisma.benutzer.findMany({
|
||||
where: {
|
||||
email: {
|
||||
|
||||
Reference in New Issue
Block a user