diff --git a/CHANGELOG.md b/CHANGELOG.md index 74cdcb7..441617d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,152 +1,3 @@ -## [2026-01-26] - -### ✨ Features -- add input validation & security improvements for login/register API (683b1c0) - @Kartikey-0 -- add Docker Compose configuration for MongoDB, application, and Mongo Express services. (0e33768) - @saiusesgithub -- add audio recording and attachment support for notes (13b37b7) - @Diksha Dabhole -- Add audio recording attachments to notes (Issue #122) (2df98ac) - @Diksha Dabhole - -### πŸ“ Documentation -- auto update changelog (f630373) - @vinayboss9669 -- auto update changelog (83dca1b) - @vinayboss9669 -- auto update changelog (2239ad3) - @vinayboss9669 -- auto update changelog (0a88bb5) - @vinayboss9669 -- auto update changelog (aba5ef7) - @HarshYadav152 -- auto update changelog (27786d4) - @HarshYadav152 - -### πŸ“¦ Other Changes -- Fixed (fd465e1) - @Aagman Pal -- Note Viewer Error Fixed (f5dca9a) - @Aagman Pal -- added Password Visibility Toggle (198b3b6) - @Abhijeet-980 -- Note View Modal Added (c8ca166) - @Aagman Pal -- Update savebook/docker-compose.yml (5ed7f01) - @Sai Srujan Punati -- Update savebook/.dockerignore (ad968c3) - @Sai Srujan Punati -- Update savebook/.dockerignore (1320235) - @Sai Srujan Punati -- Update savebook/.dockerignore (9812ccc) - @Sai Srujan Punati -- Fix audio upload error handling in AddNote (73d431b) - @Diksha Dabhole -- Add weblinks with preview in notes (19fc09d) - @Suvam Chatterjee - - -## [2026-01-26] - -### ✨ Features -- add Docker Compose configuration for MongoDB, application, and Mongo Express services. (0e33768) - @saiusesgithub -- add audio recording and attachment support for notes (13b37b7) - @Diksha Dabhole -- Add audio recording attachments to notes (Issue #122) (2df98ac) - @Diksha Dabhole -- add image upload support for notes and user media (8cab3d7) - @avdhut400 - -### πŸ“ Documentation -- auto update changelog (83dca1b) - @vinayboss9669 -- auto update changelog (2239ad3) - @vinayboss9669 -- auto update changelog (0a88bb5) - @vinayboss9669 -- auto update changelog (aba5ef7) - @HarshYadav152 -- auto update changelog (27786d4) - @HarshYadav152 -- auto update changelog (45e18fe) - @HarshYadav152 - -### πŸ“¦ Other Changes -- Fixed (fd465e1) - @Aagman Pal -- Note Viewer Error Fixed (f5dca9a) - @Aagman Pal -- added Password Visibility Toggle (198b3b6) - @Abhijeet-980 -- Note View Modal Added (c8ca166) - @Aagman Pal -- Update savebook/docker-compose.yml (5ed7f01) - @Sai Srujan Punati -- Update savebook/.dockerignore (ad968c3) - @Sai Srujan Punati -- Update savebook/.dockerignore (1320235) - @Sai Srujan Punati -- Update savebook/.dockerignore (9812ccc) - @Sai Srujan Punati -- Fix audio upload error handling in AddNote (73d431b) - @Diksha Dabhole -- Add weblinks with preview in notes (19fc09d) - @Suvam Chatterjee - - -## [2026-01-23] - -### ✨ Features -- add Docker Compose configuration for MongoDB, application, and Mongo Express services. (0e33768) - @saiusesgithub -- add audio recording and attachment support for notes (13b37b7) - @Diksha Dabhole -- Add audio recording attachments to notes (Issue #122) (2df98ac) - @Diksha Dabhole -- add image upload support for notes and user media (8cab3d7) - @avdhut400 - -### πŸ“ Documentation -- auto update changelog (2239ad3) - @vinayboss9669 -- auto update changelog (0a88bb5) - @vinayboss9669 -- auto update changelog (aba5ef7) - @HarshYadav152 -- auto update changelog (27786d4) - @HarshYadav152 -- auto update changelog (45e18fe) - @HarshYadav152 - -### πŸ“¦ Other Changes -- added Password Visibility Toggle (198b3b6) - @Abhijeet-980 -- Update savebook/docker-compose.yml (5ed7f01) - @Sai Srujan Punati -- Update savebook/.dockerignore (ad968c3) - @Sai Srujan Punati -- Update savebook/.dockerignore (1320235) - @Sai Srujan Punati -- Update savebook/.dockerignore (9812ccc) - @Sai Srujan Punati -- Fix audio upload error handling in AddNote (73d431b) - @Diksha Dabhole -- Add weblinks with preview in notes (19fc09d) - @Suvam Chatterjee -- Add user-media upload route and improve profile upload with size & type validation (088149c) - @avdhut400 -- Add user-media upload route and improve profile upload with size & type validation (c4cfa6d) - @avdhut400 -- route (7edcf39) - @avdhut400 -- await (fab37c8) - @Avdhut Magar - - -## [2026-01-21] - -### ✨ Features -- add audio recording and attachment support for notes (13b37b7) - @Diksha Dabhole -- Add audio recording attachments to notes (Issue #122) (2df98ac) - @Diksha Dabhole -- add image upload support for notes and user media (8cab3d7) - @avdhut400 -- add image upload support for notes (fbf9438) - @avdhut400 - -### πŸ› Bug Fixes -- improve register page validation and error handling (5f451a0) - @Diksha Dabhole -- replace browser popup with in-app modal (0662c42) - @saburi004 - -### πŸ“ Documentation -- auto update changelog (0a88bb5) - @vinayboss9669 -- auto update changelog (aba5ef7) - @HarshYadav152 -- auto update changelog (27786d4) - @HarshYadav152 -- auto update changelog (45e18fe) - @HarshYadav152 -- auto update changelog (b7af96d) - @vinayboss9669 -- auto update changelog (f777e40) - @vinayboss9669 - -### πŸ“¦ Other Changes -- added Password Visibility Toggle (198b3b6) - @Abhijeet-980 -- Fix audio upload error handling in AddNote (73d431b) - @Diksha Dabhole -- Add weblinks with preview in notes (19fc09d) - @Suvam Chatterjee -- Add user-media upload route and improve profile upload with size & type validation (088149c) - @avdhut400 -- Add user-media upload route and improve profile upload with size & type validation (c4cfa6d) - @avdhut400 -- route (7edcf39) - @avdhut400 -- await (fab37c8) - @Avdhut Magar -- Add scroll to top button (4545a0a) - @Harishchandra Gandhare - - -## [2026-01-19] - -### ✨ Features -- add audio recording and attachment support for notes (13b37b7) - @Diksha Dabhole -- Add audio recording attachments to notes (Issue #122) (2df98ac) - @Diksha Dabhole -- add image upload support for notes and user media (8cab3d7) - @avdhut400 -- add image upload support for notes (fbf9438) - @avdhut400 - -### πŸ› Bug Fixes -- improve register page validation and error handling (5f451a0) - @Diksha Dabhole -- replace browser popup with in-app modal (0662c42) - @saburi004 - -### πŸ“ Documentation -- auto update changelog (aba5ef7) - @HarshYadav152 -- auto update changelog (27786d4) - @HarshYadav152 -- auto update changelog (45e18fe) - @HarshYadav152 -- auto update changelog (b7af96d) - @vinayboss9669 -- auto update changelog (f777e40) - @vinayboss9669 -- auto update changelog (c727431) - @HarshYadav152 - -### πŸ“¦ Other Changes -- Fix audio upload error handling in AddNote (73d431b) - @Diksha Dabhole -- Add weblinks with preview in notes (19fc09d) - @Suvam Chatterjee -- Add user-media upload route and improve profile upload with size & type validation (088149c) - @avdhut400 -- Add user-media upload route and improve profile upload with size & type validation (c4cfa6d) - @avdhut400 -- route (7edcf39) - @avdhut400 -- await (fab37c8) - @Avdhut Magar -- Add scroll to top button (4545a0a) - @Harishchandra Gandhare -- WIP: my changes before syncing upstream (8687fe5) - @avdhut400 - - ## [2026-01-19] ### ✨ Features diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..3561ce4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "SaveBook", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/savebook/.dockerignore b/savebook/.dockerignore index c592f96..4f810a7 100644 --- a/savebook/.dockerignore +++ b/savebook/.dockerignore @@ -4,6 +4,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* +package-lock.json yarn.lock pnpm-lock.yaml @@ -31,6 +32,9 @@ build # Debug npm-debug.log* +yarn-debug.log* +yarn-error.log* + # Local env files .env.local .env.development.local diff --git a/savebook/app/(auth)/login/page.js b/savebook/app/(auth)/login/page.js index d495c24..0e552a7 100644 --- a/savebook/app/(auth)/login/page.js +++ b/savebook/app/(auth)/login/page.js @@ -3,7 +3,6 @@ import { useAuth } from "@/context/auth/authContext"; import { useRouter } from "next/navigation"; import React, { useState, useEffect } from "react"; -import toast from "react-hot-toast"; import Link from "next/link"; import { Eye, EyeOff } from "lucide-react"; @@ -13,14 +12,11 @@ import { Eye, EyeOff } from "lucide-react"; ========================= */ const LoginForm = () => { const { login, isAuthenticated, loading } = useAuth(); - const router = useRouter(); - - const [credentials, setCredentials] = useState({ - username: "", - password: "", - }); - - const [isLoading, setIsLoading] = useState(false); + const [credentials, setCredentials] = useState({ username: "", password: "" }); + const [rememberMe, setRememberMe] = useState(false); + const [errors, setErrors] = useState({}); + const [errorMessage, setErrorMessage] = useState(""); + const [successMessage, setSuccessMessage] = useState(""); const [hasRedirected, setHasRedirected] = useState(false); const [showPassword, setShowPassword] = useState(false); @@ -28,112 +24,109 @@ const LoginForm = () => { const [recoveryCodes, setRecoveryCodes] = useState(null); const [showRecoveryModal, setShowRecoveryModal] = useState(false); - /* ------------------------- - Redirect after login - ------------------------- */ + // Redirect after login useEffect(() => { - if ( - isAuthenticated && - !loading && - !hasRedirected && - !showRecoveryModal - ) { + if (isAuthenticated && !loading && !hasRedirected) { setHasRedirected(true); router.push("/notes"); } - }, [isAuthenticated, loading, hasRedirected, showRecoveryModal, router]); + }, [isAuthenticated, loading, hasRedirected, router]); + + const onChange = (e) => { + setCredentials({ ...credentials, [e.target.name]: e.target.value }); + }; - /* ------------------------- - Submit - ------------------------- */ const handleSubmit = async (e) => { e.preventDefault(); - if (isLoading || isAuthenticated) return; + setErrors({}); + setErrorMessage(""); + setSuccessMessage(""); - setIsLoading(true); + const newErrors = {}; + if (!credentials.username.trim()) { + newErrors.username = "Username is required"; + } + if (!credentials.password) { + newErrors.password = "Password is required"; + } + if (Object.keys(newErrors).length > 0) { + setErrors(newErrors); + return; + } try { - const result = await login( - credentials.username, - credentials.password - ); + const result = await login(credentials.username, credentials.password, rememberMe); if (result.success) { - toast.success("Welcome back! πŸŽ‰"); - - // First login show recovery codes - if (result.recoveryCodes && result.recoveryCodes.length > 0) { - setRecoveryCodes(result.recoveryCodes); - setShowRecoveryModal(true); - } + setSuccessMessage("Logging in..."); + setErrorMessage(""); + // redirect handled by useEffect } else { - toast.error(result.message || "Invalid credentials"); + setSuccessMessage(""); + setErrorMessage(result.message); } - } catch (err) { - toast.error("Something went wrong"); - } finally { - setIsLoading(false); + } catch (error) { + // Removed console.error + setSuccessMessage(""); + setErrorMessage("Something went wrong. Please try again."); } }; - /* ------------------------- - Helpers - ------------------------- */ - const onchange = (e) => - setCredentials({ ...credentials, [e.target.name]: e.target.value }); - - const handleCopy = async () => { - await navigator.clipboard.writeText(recoveryCodes.join("\n")); - toast.success("Recovery codes copied"); - }; - - const handleDownload = () => { - const blob = new Blob([recoveryCodes.join("\n")], { - type: "text/plain", - }); - const url = URL.createObjectURL(blob); - - const a = document.createElement("a"); - a.href = url; - a.download = "savebook-recovery-codes.txt"; - a.click(); - - URL.revokeObjectURL(url); - }; - - if (loading) return ; - return ( - <> - {/* ========== LOGIN FORM ========== */} -
- {/* Username */} -
-