Merged in fix/SW-1942-case-in-sensitive-find-my-booking (pull request #1552)

fix(SW-1942): fixed find my booking to be case-insensitive on form input

Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Christian Andolf
2025-03-17 15:34:00 +00:00
2 changed files with 41 additions and 4 deletions

View File

@@ -16,6 +16,9 @@ describe("Access booking", () => {
it("should enable access if all is provided", () => { it("should enable access if all is provided", () => {
expect(accessBooking(loggedIn, "Booking", user)).toBe(ACCESS_GRANTED) expect(accessBooking(loggedIn, "Booking", user)).toBe(ACCESS_GRANTED)
}) })
it("should enable access if all is provided and be case-insensitive", () => {
expect(accessBooking(loggedIn, "BoOkInG", user)).toBe(ACCESS_GRANTED)
})
it("should prompt to login", () => { it("should prompt to login", () => {
expect(accessBooking(loggedIn, "Booking", null)).toBe(ERROR_UNAUTHORIZED) expect(accessBooking(loggedIn, "Booking", null)).toBe(ERROR_UNAUTHORIZED)
}) })
@@ -35,6 +38,39 @@ describe("Access booking", () => {
ACCESS_GRANTED ACCESS_GRANTED
) )
}) })
it("should enable access if all is provided and be case-insensitive for first name", () => {
const cookieString = new URLSearchParams({
confirmationNumber: "123456789",
firstName: "AnOnYmOuS",
lastName: "Booking",
email: "logged+out@scandichotels.com",
}).toString()
expect(accessBooking(loggedOut, "Booking", null, cookieString)).toBe(
ACCESS_GRANTED
)
})
it("should enable access if all is provided and be case-insensitive for last name", () => {
const cookieString = new URLSearchParams({
confirmationNumber: "123456789",
firstName: "Anonymous",
lastName: "Booking",
email: "logged+out@scandichotels.com",
}).toString()
expect(accessBooking(loggedOut, "BoOkInG", null, cookieString)).toBe(
ACCESS_GRANTED
)
})
it("should enable access if all is provided and be case-insensitive for email", () => {
const cookieString = new URLSearchParams({
confirmationNumber: "123456789",
firstName: "Anonymous",
lastName: "Booking",
email: "LOGGED+out@scandichotels.com",
}).toString()
expect(accessBooking(loggedOut, "Booking", null, cookieString)).toBe(
ACCESS_GRANTED
)
})
it("should prompt logout if user is logged in", () => { it("should prompt logout if user is logged in", () => {
const cookieString = new URLSearchParams({ const cookieString = new URLSearchParams({
confirmationNumber: "123456789", confirmationNumber: "123456789",

View File

@@ -21,7 +21,7 @@ function accessBooking(
) { ) {
if (guest.membershipNumber) { if (guest.membershipNumber) {
if (user) { if (user) {
if (lastName === guest.lastName) { if (lastName.toLowerCase() === guest.lastName?.toLowerCase()) {
return ACCESS_GRANTED return ACCESS_GRANTED
} }
} else { } else {
@@ -32,7 +32,7 @@ function accessBooking(
} }
} }
if (guest.lastName === lastName) { if (guest.lastName?.toLowerCase() === lastName.toLowerCase()) {
if (user) { if (user) {
console.warn( console.warn(
"Access to booking not granted due to logged in user attempting access to anonymous booking" "Access to booking not granted due to logged in user attempting access to anonymous booking"
@@ -41,8 +41,9 @@ function accessBooking(
} else { } else {
const params = new URLSearchParams(cookie) const params = new URLSearchParams(cookie)
if ( if (
params.get("firstName") === guest.firstName && params.get("firstName")?.toLowerCase() ===
params.get("email") === guest.email guest.firstName?.toLowerCase() &&
params.get("email")?.toLowerCase() === guest.email?.toLowerCase()
) { ) {
return ACCESS_GRANTED return ACCESS_GRANTED
} else { } else {