Update security for dashboard and details pages.
This commit is contained in:
@@ -5,15 +5,15 @@ import { ok, methodNotAllowed, unauthorized } from 'lib/response';
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { user_id, is_admin } = req.auth;
|
||||
const { userId } = req.query;
|
||||
const { user_id: current_user_id, is_admin } = req.auth;
|
||||
const { user_id } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (userId && !is_admin) {
|
||||
if (user_id && !is_admin) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const websites = await getUserWebsites(+userId || user_id);
|
||||
const websites = await getUserWebsites(+user_id || current_user_id);
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user