mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Fixed password update.
This commit is contained in:
parent
2713e3316a
commit
8b966a04b0
@ -35,10 +35,7 @@ export default function MetricsTable({
|
|||||||
const { get, useQuery } = useApi();
|
const { get, useQuery } = useApi();
|
||||||
|
|
||||||
const { data, isLoading, isFetched, error } = useQuery(
|
const { data, isLoading, isFetched, error } = useQuery(
|
||||||
[
|
['websites:metrics', websiteId, type, modified, url, referrer, os, browser, device, country],
|
||||||
'websites:metrics',
|
|
||||||
{ websiteId, type, modified, url, referrer, os, browser, device, country },
|
|
||||||
],
|
|
||||||
() =>
|
() =>
|
||||||
get(`/websites/${websiteId}/metrics`, {
|
get(`/websites/${websiteId}/metrics`, {
|
||||||
type,
|
type,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { NextApiRequestQueryBody, User } from 'lib/types';
|
import { NextApiRequestQueryBody, User } from 'lib/types';
|
||||||
import { canUpdateUser } from 'lib/auth';
|
|
||||||
import { useAuth } from 'lib/middleware';
|
import { useAuth } from 'lib/middleware';
|
||||||
import { NextApiResponse } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import {
|
import {
|
||||||
@ -9,7 +8,6 @@ import {
|
|||||||
methodNotAllowed,
|
methodNotAllowed,
|
||||||
forbidden,
|
forbidden,
|
||||||
ok,
|
ok,
|
||||||
unauthorized,
|
|
||||||
} from 'next-basics';
|
} from 'next-basics';
|
||||||
import { getUser, updateUser } from 'queries';
|
import { getUser, updateUser } from 'queries';
|
||||||
|
|
||||||
@ -33,13 +31,9 @@ export default async (
|
|||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
|
|
||||||
const { currentPassword, newPassword } = req.body;
|
const { currentPassword, newPassword } = req.body;
|
||||||
const { id } = req.query;
|
const { id } = req.auth.user;
|
||||||
|
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
if (!(await canUpdateUser(req.auth, id))) {
|
|
||||||
return unauthorized(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = await getUser({ id }, { includePassword: true });
|
const user = await getUser({ id }, { includePassword: true });
|
||||||
|
|
||||||
if (!checkPassword(currentPassword, user.password)) {
|
if (!checkPassword(currentPassword, user.password)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user