mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-13 04:37:39 +02:00
Merge branch '273-bug-tenantdomain-is-interpreted-inconsistently-confirm-invite-urls-are-malformed' of github.com:open-reception/appointment-booking-software into 273-bug-tenantdomain-is-interpreted-inconsistently-confirm-invite-urls-are-malformed
This commit is contained in:
@@ -467,7 +467,13 @@ describe("Email System", () => {
|
||||
const confirmationCode = "ABC123";
|
||||
const expirationMinutes = 15;
|
||||
|
||||
await sendConfirmationEmail(staffUser, mockTenant, confirmationCode, expirationMinutes);
|
||||
await sendConfirmationEmail(
|
||||
staffUser,
|
||||
mockTenant,
|
||||
confirmationCode,
|
||||
expirationMinutes,
|
||||
new URL("https://example.com"),
|
||||
);
|
||||
|
||||
expect(mockSendMail).toHaveBeenCalled();
|
||||
});
|
||||
@@ -506,7 +512,13 @@ describe("Email System", () => {
|
||||
const confirmationCode = "XYZ789";
|
||||
const expirationMinutes = 10;
|
||||
|
||||
await sendConfirmationEmail(staffUser, mockTenant, confirmationCode, expirationMinutes);
|
||||
await sendConfirmationEmail(
|
||||
staffUser,
|
||||
mockTenant,
|
||||
confirmationCode,
|
||||
expirationMinutes,
|
||||
new URL("https://example.com"),
|
||||
);
|
||||
|
||||
expect(mockSendMail).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -433,7 +433,7 @@ export async function sendConfirmationEmail(
|
||||
tenant: SelectTenant,
|
||||
confirmationCode: string,
|
||||
expirationMinutes: number = 15,
|
||||
requestUrl?: URL,
|
||||
requestUrl: URL,
|
||||
): Promise<void> {
|
||||
// Generate appropriate base URL if request URL is provided
|
||||
const baseUrl = requestUrl ? generateBaseUrl(requestUrl, tenant) : "http://localhost:5173";
|
||||
|
||||
@@ -124,7 +124,7 @@ describe("UserService", () => {
|
||||
.mockReturnValueOnce(mockInviteInsertBuilder)
|
||||
.mockReturnValueOnce(mockInsertBuilder);
|
||||
|
||||
const result = await UserService.createUser(adminData);
|
||||
const result = await UserService.createUser(adminData, new URL("http://localhost:5173"));
|
||||
|
||||
expect(mockCentralDb.insert).toHaveBeenCalled();
|
||||
expect(mockInsertBuilder.values).toHaveBeenCalledWith({
|
||||
@@ -158,7 +158,7 @@ describe("UserService", () => {
|
||||
|
||||
mockCentralDb.update.mockReturnValue(mockUpdateBuilder);
|
||||
|
||||
await UserService.resendConfirmationEmail(email);
|
||||
await UserService.resendConfirmationEmail(email, new URL("http://localhost:5173"));
|
||||
|
||||
expect(mockCentralDb.update).toHaveBeenCalled();
|
||||
expect(mockUpdateBuilder.set).toHaveBeenCalledWith({
|
||||
@@ -180,7 +180,9 @@ describe("UserService", () => {
|
||||
|
||||
mockCentralDb.update.mockReturnValue(mockUpdateBuilder);
|
||||
|
||||
await expect(UserService.resendConfirmationEmail(email)).rejects.toThrow(NotFoundError);
|
||||
await expect(
|
||||
UserService.resendConfirmationEmail(email, new URL("http://localhost:5173")),
|
||||
).rejects.toThrow(NotFoundError);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export class UserService {
|
||||
/**
|
||||
* Create a new user
|
||||
*/
|
||||
static async createUser(userData: UserCreation, requestUrl?: URL) {
|
||||
static async createUser(userData: UserCreation, requestUrl: URL) {
|
||||
const log = logger.setContext("UserService");
|
||||
log.debug("Creating new user account", {
|
||||
email: userData.email,
|
||||
@@ -218,9 +218,9 @@ export class UserService {
|
||||
/**
|
||||
* Resend the confirmation email for a user
|
||||
* @param email - Email of the user to confirm
|
||||
* @param requestUrl - Optional request URL for generating correct baseUrl
|
||||
* @param requestUrl - request URL for generating correct baseUrl
|
||||
*/
|
||||
static async resendConfirmationEmail(email: string, requestUrl?: URL): Promise<void> {
|
||||
static async resendConfirmationEmail(email: string, requestUrl: URL): Promise<void> {
|
||||
const log = logger.setContext("UserService");
|
||||
log.debug("Resending confirmation email", { email });
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { dev } from "$app/environment";
|
||||
import { UniversalLogger } from "$lib/logger";
|
||||
import { sendConfirmationEmail } from "$lib/server/email/email-service";
|
||||
import { registerOpenAPIRoute } from "$lib/server/openapi";
|
||||
@@ -205,7 +206,7 @@ export const POST: RequestHandler = async ({ request, locals, url }) => {
|
||||
tenant,
|
||||
invitation.inviteCode,
|
||||
10, // 10 minutes expiration to match tokenValidUntil
|
||||
url,
|
||||
dev ? url : new URL(`https://${tenant.domain}`),
|
||||
);
|
||||
|
||||
logger.debug("User invitation sent successfully", {
|
||||
|
||||
Reference in New Issue
Block a user