Skip to content

Commit

Permalink
Add username/pass check
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 7, 2024
1 parent 9db144e commit 72d15c4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 72d15c4

Please sign in to comment.