0
0
Fork 0

Restructure login endpoint changes to include account's admin status

This commit is contained in:
Oliver Akins 2022-07-31 17:47:54 -06:00
parent a7d7c019e5
commit d962bfc01e
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
3 changed files with 8 additions and 7 deletions

View file

@ -3,15 +3,16 @@ import { db } from "@/main";
const data: ServerRoute = {
method: `POST`, path: `/login`,
options: {},
async handler(request, h) {
const { access } = request.auth.credentials as { username: string, access: string[] };
const { access, admin } = request.auth.credentials as { username: string, access: string[]; admin: boolean };
let channels = access.filter(x => x != "*");
if (access.includes(`*`)) {
channels.push(...Object.keys(db).filter(c => !channels.includes(c)));
};
return h.response(channels).code(200);
return h.response({ admin, channels }).code(200);
},
};
export default data;