Skip to content

Commit aafc65e

Browse files
authored
Merge pull request #189 from Peppermint-Lab/next
bugfixes
2 parents 88c6679 + 54965ea commit aafc65e

File tree

9 files changed

+1016
-13512
lines changed

9 files changed

+1016
-13512
lines changed

apps/api/src/controllers/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ export function authRoutes(fastify: FastifyInstance) {
230230
});
231231

232232
reply.send({
233-
sucess: true,
233+
success: true,
234234
});
235235
} else {
236236
reply.send({
237-
sucess: false,
237+
success: false,
238238
});
239239
}
240240
}

apps/client/components/ResetPassword/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import { Dialog, Transition } from "@headlessui/react";
22
import { XMarkIcon } from "@heroicons/react/24/outline";
3+
import { notifications } from "@mantine/notifications";
4+
import { getCookie } from "cookies-next";
35
import React, { Fragment, useState } from "react";
46

5-
export default function ResetPassword({ user }) {
7+
export default function ResetPassword() {
68
const [open, setOpen] = useState(false);
79
const [password, setPassword] = useState("");
810
const [check, setCheck] = useState("");
911

1012
const postData = async () => {
11-
if (check === password && password.length > 0) {
13+
if (check === password && password.length > 3) {
1214
await fetch(
1315
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/reset-password`,
1416
{
1517
method: "POST",
1618
headers: {
1719
"Content-Type": "application/json",
18-
Authorization: "Bearer " + token,
20+
Authorization: "Bearer " + getCookie("session"),
1921
},
2022
body: JSON.stringify({
2123
password,
@@ -24,7 +26,7 @@ export default function ResetPassword({ user }) {
2426
)
2527
.then((res) => res.json())
2628
.then((res) => {
27-
if (res.failed === false) {
29+
if (res.success) {
2830
notifications.show({
2931
title: "Success",
3032
message: `Password updated :)`,
@@ -34,7 +36,7 @@ export default function ResetPassword({ user }) {
3436
} else {
3537
notifications.show({
3638
title: "Error",
37-
message: `Error: ${res.message}`,
39+
message: `Error: failed to update password`,
3840
color: "red",
3941
autoClose: 5000,
4042
});

apps/client/layouts/adminLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function AdminLayout({ children }: any) {
1313

1414
const { user } = useUser();
1515

16-
if (user || user.role === "admin") {
16+
if (user && !user.isAdmin) {
1717
return (
1818
<div className="flex items-center justify-center h-screen">
1919
<h1 className="text-4xl font-bold">You are not an admin</h1>

apps/client/layouts/newLayout.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
HomeIcon,
88
XMarkIcon,
99
} from "@heroicons/react/24/outline";
10-
import { deleteCookie } from "cookies-next";
10+
import { deleteCookie, getCookie } from "cookies-next";
1111
import Link from "next/link";
1212
import { useRouter } from "next/router";
1313
import { Fragment, useCallback, useEffect, useState } from "react";
@@ -90,7 +90,14 @@ export default function NewLayout({ children }: any) {
9090
async function logout() {
9191
// clears session on server
9292
const res = await fetch(
93-
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/user/${user.id}/logout`
93+
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/user/${user.id}/logout`,
94+
{
95+
method: "GET",
96+
headers: {
97+
"Content-Type": "application/json",
98+
Authorization: `Bearer ${getCookie("session")}`,
99+
},
100+
}
94101
).then((res) => res.json());
95102

96103
// delete session cookie

apps/client/pages/admin/users/internal/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ const fetchUsers = async (token) => {
2525

2626
function DefaultColumnFilter({ column: { filterValue, setFilter } }) {
2727
return (
28-
<input
29-
className="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md"
30-
type="text"
31-
value={filterValue || ""}
32-
onChange={(e) => {
33-
setFilter(e.target.value || undefined); // Set undefined to remove the filter entirely
34-
}}
35-
placeholder="Type to filter"
36-
/>
28+
// <input
29+
// className="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md"
30+
// type="text"
31+
// value={filterValue || ""}
32+
// autoComplete="off"
33+
// onChange={(e) => {
34+
// setFilter(e.target.value || undefined); // Set undefined to remove the filter entirely
35+
// }}
36+
// placeholder="Type to filter"
37+
// />
38+
<></>
3739
);
3840
}
3941
function Table({ columns, data }) {

apps/client/pages/settings/password.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function PasswordChange({ children }) {
1010
const [check, setCheck] = useState("");
1111

1212
const postData = async () => {
13-
if (check === password && password.length > 0) {
13+
if (check === password && password.length > 2) {
1414
await fetch(
1515
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/reset-password`,
1616
{
@@ -26,7 +26,7 @@ export default function PasswordChange({ children }) {
2626
)
2727
.then((res) => res.json())
2828
.then((res) => {
29-
if (res.failed === false) {
29+
if (res.success) {
3030
notifications.show({
3131
title: "Success",
3232
message: `Password updated :)`,
@@ -36,7 +36,7 @@ export default function PasswordChange({ children }) {
3636
} else {
3737
notifications.show({
3838
title: "Error",
39-
message: `Error: ${res.message}`,
39+
message: `Error: Failed to update password`,
4040
color: "red",
4141
autoClose: 5000,
4242
});

apps/docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"dev": "next",
7+
"dev": "next -p 3005",
88
"build": "next build",
99
"start": "next start"
1010
},
1111
"keywords": [],
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"next": "^14.0.3",
15+
"next": "13",
1616
"nextra": "^2.13.2",
1717
"nextra-theme-docs": "^2.13.2",
1818
"react": "^18.2.0",

0 commit comments

Comments
 (0)