From 9a622004ea488783127abd83f3f4caf779a5aabb Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Sun, 25 Aug 2024 16:54:19 -0400 Subject: [PATCH] fix: fix 500 when check-app has bad url --- src/backend/src/api/APIError.js | 4 ++++ src/backend/src/services/auth/AuthService.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/backend/src/api/APIError.js b/src/backend/src/api/APIError.js index 93bee20fc..70b9628dd 100644 --- a/src/backend/src/api/APIError.js +++ b/src/backend/src/api/APIError.js @@ -482,6 +482,10 @@ module.exports = class APIError { status: 422, message: 'This share can not be applied to this user.', }, + 'no_origin_for_app': { + status: 400, + message: 'Puter apps must have a valid URL.' + }, // Chat // TODO: specifying these errors here might be a violation diff --git a/src/backend/src/services/auth/AuthService.js b/src/backend/src/services/auth/AuthService.js index ea0dfe451..d8ab3eb95 100644 --- a/src/backend/src/services/auth/AuthService.js +++ b/src/backend/src/services/auth/AuthService.js @@ -442,6 +442,9 @@ class AuthService extends BaseService { async app_uid_from_origin (origin) { origin = this._origin_from_url(origin); + if ( origin === null ) { + throw APIError.create('no_origin_for_app'); + } return await this._app_uid_from_origin(origin); }