mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 17:45:38 +01:00
API security updates.
This commit is contained in:
parent
01432266ef
commit
8e3286179a
7 changed files with 115 additions and 80 deletions
|
|
@ -1,14 +1,18 @@
|
|||
import { getAccountById, updateAccount } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { badRequest, methodNotAllowed, ok } from 'lib/response';
|
||||
import { badRequest, methodNotAllowed, ok, unauthorized } from 'lib/response';
|
||||
import { checkPassword, hashPassword } from 'lib/crypto';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { user_id } = req.auth;
|
||||
const { user_id, is_admin } = req.auth;
|
||||
const { current_password, new_password } = req.body;
|
||||
|
||||
if (is_admin) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
if (req.method === 'POST') {
|
||||
const account = await getAccountById(user_id);
|
||||
const valid = await checkPassword(current_password, account.password);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue