Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions backend/http/endpoint.http
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImVtYWlsI
"password": "FatimaAminu@123"
}



POST http://localhost:3000/auth/signIn
Content-Type: application/json
Expand All @@ -26,25 +27,8 @@ Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImVtYWlsI
}


GET http://localhost:3000/puzzles/daily-quest

### Get all puzzles
GET http://localhost:3000/puzzles

### Get puzzles by category
GET http://localhost:3000/puzzles?categoryId=397b1a88-3a41-4c14-afee-20f57554368b

### Get puzzles by difficulty
GET http://localhost:3000/puzzles?difficulty=INTERMEDIATE

### Get puzzles by category AND difficulty
GET http://localhost:3000/puzzles?categoryId=397b1a88-3a41-4c14-afee-20f57554368b&difficulty=INTERMEDIATE

### Get puzzles with pagination
GET http://localhost:3000/puzzles?page=1&limit=10

### Get puzzles with all filters
GET http://localhost:3000/puzzles?categoryId=397b1a88-3a41-4c14-afee-20f57554368b&difficulty=INTERMEDIATE&page=1&limit=10
GET http://localhost:3000/daily-quest
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImVtYWlsIjoiYW1pbnVmYXRpbWFAZ21haWwuY29tIiwiaWF0IjoxNzY5MzI2NTA3LCJleHAiOjE3NjkzMzAxMDcsImF1ZCI6ImxvY2FsaG9zdDozMDAwIiwiaXNzIjoibG9jYWxob3N0OjMwMDAifQ.YnrXEo1yns77DQgzHR0XO8m5MfTxT_ic9U_2je9nB6M



Expand Down
22 changes: 11 additions & 11 deletions backend/src/puzzles/controllers/puzzles.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ export class PuzzlesController {
return this.puzzlesService.create(createPuzzleDto);
}

@ApiOperation({ summary: 'Get a puzzle by ID' })
@ApiResponse({
status: 200,
description: 'Puzzle retrieved successfully',
type: Puzzle,
})
@Get(':id')
getById(@Param('id') id: string) {
return this.puzzlesService.getPuzzleById(id);
}

@ApiOperation({ summary: 'Get daily quest puzzles' })
@ApiResponse({
status: 200,
Expand All @@ -49,15 +60,4 @@ export class PuzzlesController {
findAll(@Query() query: PuzzleQueryDto) {
return this.puzzlesService.findAll(query);
}

@ApiOperation({ summary: 'Get a puzzle by ID' })
@ApiResponse({
status: 200,
description: 'Puzzle retrieved successfully',
type: Puzzle,
})
@Get(':id')
getById(@Param('id') id: string) {
return this.puzzlesService.getPuzzleById(id);
}
}
7 changes: 4 additions & 3 deletions frontend/app/auth/check-email/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use client";

import ErrorBoundary from "@/components/ErrorBoundary";
import Link from "next/link";
import Image from 'next/image';
import { useToast } from "@/components/ui/ToastProvider";
import { useState } from "react";
import Button from "@/components/ui/Button";

import { Mail } from "lucide-react";

const CheckEmail = () => {
const { showSuccess, showError } = useToast();
Expand Down Expand Up @@ -38,8 +40,7 @@ const CheckEmail = () => {
} else {
showError('Error', data.message || 'Failed to resend password reset link.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
} catch (error) {
showError('Error', 'An unexpected error occurred. Please try again later.');
} finally {
setIsLoading(false);
Expand Down
38 changes: 14 additions & 24 deletions frontend/app/auth/forgot-password/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Button from "@/components/ui/Button";
const ForgotPassword = () => {
const router = useRouter();

const { showSuccess, showError } = useToast();
const { showSuccess, showError, showWarning, showInfo } = useToast();
const [formData, setFormData] = useState({
email: '',
});
Expand Down Expand Up @@ -52,35 +52,25 @@ const ForgotPassword = () => {
}

try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/auth/forgot-password`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email: formData.email }),
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/forgot-password`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
);

body: JSON.stringify({ email: formData.email }),
});

const data = await response.json();

if (response.ok) {
// Store email for resend functionality
sessionStorage.setItem("resetEmail", formData.email);
showSuccess(
"Success",
data.message || "Password reset link sent to your email.",
);
router.push("/auth/check-email");
sessionStorage.setItem('resetEmail', formData.email);
showSuccess('Success', data.message || 'Password reset link sent to your email.');
router.push('/auth/check-email');
} else {
showError(
"Error",
data.message || "Failed to send password reset link.",
);
showError('Error', data.message || 'Failed to send password reset link.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
} catch (error) {
showError('Error', 'An unexpected error occurred. Please try again later.');
} finally {
setIsLoading(false);
Expand Down
39 changes: 16 additions & 23 deletions frontend/app/auth/reset-password/[token]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";

import ErrorBoundary from "@/components/ErrorBoundary";

import Link from "next/link";
import Image from 'next/image';
import { useRouter, useParams } from "next/navigation";
import Input from "@/components/ui/Input";
import { useToast } from "@/components/ui/ToastProvider";
Expand Down Expand Up @@ -75,39 +76,31 @@ const ResetPassword = () => {
}

try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/auth/reset-password/${token}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
password: formData.password,
}),
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/reset-password/${token}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
);
body: JSON.stringify({
password: formData.password,
}),
});

const data = await response.json();

if (response.ok) {
showSuccess("Success", data.message || "Password reset successfully.");
showSuccess('Success', data.message || 'Password reset successfully.');
// Clear the stored email
sessionStorage.removeItem("resetEmail");
localStorage.removeItem("resetEmail");
sessionStorage.removeItem('resetEmail');
localStorage.removeItem('resetEmail');
// Redirect to sign in after 1.5 seconds
setTimeout(() => {
router.push("/auth/signin");
router.push('/auth/signin');
}, 1500);
} else {
showError(
"Error",
data.message ||
"Failed to reset password. The link may have expired.",
);
showError('Error', data.message || 'Failed to reset password. The link may have expired.');
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
} catch (error) {
showError('Error', 'An unexpected error occurred. Please try again later.');
} finally {
setIsLoading(false);
Expand Down
Loading