diff --git a/.env b/.env index f15f6db0..01305471 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ MYSQL_ROOT_PASSWORD=chemistrycafefall24 # Change to your desired root password MYSQL_DATABASE=chemistry_db # Replace with your database name MYSQL_USER=chemistrycafedev # Replace with your MySQL username -MYSQL_PASSWORD=chemistrycafe # Replace with your MySQL password \ No newline at end of file +MYSQL_PASSWORD=chemistrycafe # Replace with your MySQL password diff --git a/frontend/src/API/API_Interfaces.tsx b/frontend/src/API/API_Interfaces.tsx index 10aa6568..ef84b638 100644 --- a/frontend/src/API/API_Interfaces.tsx +++ b/frontend/src/API/API_Interfaces.tsx @@ -69,7 +69,7 @@ export interface ReactionSpeciesDto { } export interface User { - id: string; + id?: string; username: string; role: string; email?: string | null; diff --git a/frontend/src/pages/RoleManagement.tsx b/frontend/src/pages/RoleManagement.tsx index e3a1c3c4..e048daa7 100644 --- a/frontend/src/pages/RoleManagement.tsx +++ b/frontend/src/pages/RoleManagement.tsx @@ -68,7 +68,9 @@ const RoleManagement: React.FC = () => { setUsers(response); // Initialize selectedRoles with each user's current role const initialRoles = response.reduce((acc, user) => { - acc[user.id] = user.role; + if(user.id){ + acc[user.id] = user.role; + } return acc; }, {} as { [key: string]: string }); setSelectedRoles(initialRoles); diff --git a/frontend/src/pages/logIn.tsx b/frontend/src/pages/logIn.tsx index 412a95e6..88ae3685 100644 --- a/frontend/src/pages/logIn.tsx +++ b/frontend/src/pages/logIn.tsx @@ -72,7 +72,6 @@ const LogIn = () => { // Check if the user already exists in the database try { const existingUser = await getUserByEmail(profileData.email); - if (existingUser) { const updatedUser = { access_token: user.access_token, @@ -89,7 +88,6 @@ const LogIn = () => { setUser(contextUser); } else { const newUser = { - id: "", username: profileData.name, email: profileData.email, role: "unverified", @@ -107,13 +105,12 @@ const LogIn = () => { email: createdUser.email, role: createdUser.role || "unverified", }; - setUser(contextUser); + setUser(createdUser); console.log("Context user ", contextUser); - alert("New user created successfully"); } } catch (error) { console.error("Error checking or creating user:", error); - alert("Error checking or creating user"); + alert("Error checking or creating user" + error); } }) .catch((error) => { diff --git a/init.sql b/init.sql index b4399acc..b8457729 100644 --- a/init.sql +++ b/init.sql @@ -798,6 +798,7 @@ INSERT IGNORE INTO users (id, username, role, email) VALUES (UUID(), 'Joshua Hare', 'admin', 'jmhhare@tamu.edu'), (UUID(), 'Nishka Mittal', 'admin', 'nishka06@tamu.edu'), (UUID(), 'Sydney Ferris', 'admin', 'sferris@tamu.edu'), + (UUID(), 'Britt Schiller', 'admin', 'brittschiller@tamu.edu'), (UUID(), 'Kyle Shores', 'admin', 'kshores@ucar.edu'); -- Link users to mechanisms