From 72d15c48080779d7bb3fbebf1e9777804de6f474 Mon Sep 17 00:00:00 2001 From: ingalls Date: Mon, 7 Oct 2024 11:58:09 -0600 Subject: [PATCH] Add username/pass check --- api/routes/login.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/routes/login.ts b/api/routes/login.ts index a5355b03a..ff390e610 100644 --- a/api/routes/login.ts +++ b/api/routes/login.ts @@ -53,10 +53,18 @@ export default async function router(schema: Schema, config: Config) { profile = await config.models.Profile.from(email); } else { - profile = await config.models.Profile.from(req.body.username); + try { + profile = await config.models.Profile.from(req.body.username); + } catch (err) { + if (err instanceof Err && err.status === 404) { + throw new Err(401, err, 'Invalid username or password'); + } else { + throw err; + } + } // Only those marked as a System Admin in the database can log in - // without TAK Server Auth and initially configure the server + // without TAK Server Auth and initially configure the server if (!profile.system_admin) { throw new Err(401, null, 'Server must be configured by a System Administrator'); }