Fix API check.

This commit is contained in:
Mike Cao 2020-09-16 13:13:50 -07:00
parent 4ab71c42a6
commit 81789d6723
2 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@ export default async (req, res) => {
const { id } = req.query; const { id } = req.query;
const user_id = +id; const user_id = +id;
if (is_admin) { if (!is_admin) {
return unauthorized(res); return unauthorized(res);
} }

View File

@ -5,16 +5,16 @@ import { ok, unauthorized, methodNotAllowed } from 'lib/response';
export default async (req, res) => { export default async (req, res) => {
await useAuth(req, res); await useAuth(req, res);
const { is_admin: current_user_is_admin } = req.auth; const { is_admin } = req.auth;
if (!is_admin) {
return unauthorized(res);
}
if (req.method === 'GET') { if (req.method === 'GET') {
if (current_user_is_admin) { const accounts = await getAccounts();
const accounts = await getAccounts();
return ok(res, accounts); return ok(res, accounts);
}
return unauthorized(res);
} }
return methodNotAllowed(res); return methodNotAllowed(res);