fix(SW-1710): use access object references instead

correct incorrect test that granted access incorrectly
This commit is contained in:
Christian Andolf
2025-03-07 14:22:33 +01:00
parent b0df70e552
commit af08b3277d
4 changed files with 24 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ export {
ACCESS_GRANTED,
accessBooking as default,
ERROR_BAD_REQUEST,
ERROR_FORBIDDEN,
ERROR_NOT_FOUND,
ERROR_UNAUTHORIZED,
}
@@ -29,14 +30,18 @@ function accessBooking(
}
if (guest.lastName === lastName) {
const params = new URLSearchParams(cookie)
if (
params.get("firstName") === guest.firstName &&
params.get("email") === guest.email
) {
return ACCESS_GRANTED
if (user) {
return ERROR_FORBIDDEN
} else {
return ERROR_BAD_REQUEST
const params = new URLSearchParams(cookie)
if (
params.get("firstName") === guest.firstName &&
params.get("email") === guest.email
) {
return ACCESS_GRANTED
} else {
return ERROR_BAD_REQUEST
}
}
}
@@ -53,6 +58,11 @@ const ERROR_UNAUTHORIZED = {
status: 401,
} as const
const ERROR_FORBIDDEN = {
code: "FORBIDDEN",
status: 403,
} as const
const ERROR_NOT_FOUND = {
code: "NOT_FOUND",
status: 404,