Restructure login endpoint changes to include account's admin status
This commit is contained in:
parent
a7d7c019e5
commit
d962bfc01e
3 changed files with 8 additions and 7 deletions
|
|
@ -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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue