diff --git a/Controllers/userController.js b/Controllers/userController.js index 4f5847e..43bf6fe 100644 --- a/Controllers/userController.js +++ b/Controllers/userController.js @@ -75,7 +75,6 @@ const registerUser = async (req, res) => { }) ); //Using this so we don't send the actual hash to the front-end - user.password = "******"; logger.info(`User Added Successfully`, { log: JSON.stringify(user) }); @@ -142,7 +141,7 @@ const loginUser = async (req, res) => { //This logs the user out the app by removing the //Users token const logout = (req, res) => { - res.clearCookie("token", { + res.clearCookie("authToken", { httpOnly: true, secure: true, sameSite: "None", diff --git a/Routes/User.js b/Routes/User.js index 0be96fb..88661be 100644 --- a/Routes/User.js +++ b/Routes/User.js @@ -6,7 +6,7 @@ const auth = require("../middleware/auth") router.get("/authorized", auth, userController.authorized); -router.get("/logout", userController.logout); +router.post("/logout", userController.logout); router.post("/login", rateLimiter, userController.loginUser); router.post("/register", rateLimiter, userController.registerUser); router.patch("/updateaccount", auth, userController.updateAccount); diff --git a/package.json b/package.json index c589068..165f9e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "building-u-feedback-api", - "version": "v0.4.0-alpha", + "version": "v0.4.1-alpha", "description": "This is for the server api that serves the app", "main": "index.js", "scripts": { diff --git a/views/package.json b/views/package.json index 312000a..e373853 100644 --- a/views/package.json +++ b/views/package.json @@ -1,6 +1,6 @@ { "name": "building-u-feedback", - "version": "v0.2.0-alpha", + "version": "v0.2.1-alpha", "homepage": "https://buildingu.github.io/Building-u-feedback", "type": "module", "scripts": { diff --git a/views/src/App.jsx b/views/src/App.jsx index 99d1420..1ffef7f 100644 --- a/views/src/App.jsx +++ b/views/src/App.jsx @@ -22,7 +22,9 @@ function App() { {({ user }) => }} /> {({ user }) => }} /> } /> - } /> + {/* wasnt sure how to do this correctly but this route enables pages that dont match our routes to land + on the 404 page */} + } /> ); diff --git a/views/src/Pages/Interndashboard.jsx b/views/src/Pages/Interndashboard.jsx index 9237ccc..46d2ee1 100644 --- a/views/src/Pages/Interndashboard.jsx +++ b/views/src/Pages/Interndashboard.jsx @@ -9,7 +9,7 @@ import Account from '../Pages/Account/'; import TopBar from '../components/TopBar'; function Interndashboard(props) { - const mockdata = [ + const navItems = [ { icon: IconFilePlus, label: 'Create Feedback request', to: 'requestform' }, { icon: IconClipboardText, label: 'Feedback Requests', to: 'myrequests' }, { icon: IconUser, label: 'Account', to: 'account' }, @@ -20,7 +20,7 @@ function Interndashboard(props) { return (
- + } /> } /> diff --git a/views/src/Pages/LoginPage.jsx b/views/src/Pages/LoginPage.jsx index cd353b6..8ba45e5 100644 --- a/views/src/Pages/LoginPage.jsx +++ b/views/src/Pages/LoginPage.jsx @@ -132,7 +132,7 @@ function LoginPage() {
- Don't An Account? + Don't Have An Account? Sign Up diff --git a/views/src/Pages/Signup.jsx b/views/src/Pages/Signup.jsx index 974b579..fd5f699 100644 --- a/views/src/Pages/Signup.jsx +++ b/views/src/Pages/Signup.jsx @@ -1,8 +1,8 @@ import React from "react"; import { useForm } from "@mantine/form"; import { useNavigate } from "react-router-dom"; -import { useDispatch } from "react-redux"; // Import useDispatch -import { setUser } from "../features/Auth/authSlice"; // Import your auth slice actions +import { useDispatch } from "react-redux"; +import { setUser } from "../features/Auth/authSlice"; import axios from "axios"; import { TextInput, @@ -49,10 +49,9 @@ function Signup() { }); const handleFormSubmit = async () => { - // Trigger form validation form.validate(); - if (form.isValid) { + if (form.isValid()) { const userData = { fName: form.values.fName, userName: form.values.userName, @@ -62,7 +61,8 @@ function Signup() { try { const response = await axios.post( `${baseUrl}/api/users/register`, - userData + userData, + { withCredentials: true } ); if (response.status === 201) { @@ -80,9 +80,6 @@ function Signup() { } catch (error) { console.error("Error submitting the form data:", error); } - } else { - // Handle the case when the form is not valid (TBD) - return; } }; diff --git a/views/src/features/Auth/authSlice.js b/views/src/features/Auth/authSlice.js index eb557f0..4fd2947 100644 --- a/views/src/features/Auth/authSlice.js +++ b/views/src/features/Auth/authSlice.js @@ -15,8 +15,8 @@ const initialState = { export const logoutUser = createAsyncThunk('auth/logout', async (_, thunkAPI) => { try { - await axios.get( - `${baseUrl}/api/users/logout'`, + await axios.post( + `${baseUrl}/api/users/logout`, { withCredentials: true } diff --git a/views/vite.config.js b/views/vite.config.js index 6e8bc79..28ede46 100644 --- a/views/vite.config.js +++ b/views/vite.config.js @@ -4,7 +4,7 @@ import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - base: '/Building-u-feedback/', + base: '/Building-u-feedback', ////Uncomment for local development only // server: {