Skip to content

Commit

Permalink
Merge pull request #61 from NCAR/properties
Browse files Browse the repository at this point in the history
fixed authentication bug
  • Loading branch information
JoshHare authored Nov 12, 2024
2 parents 2c13ab2 + 9f31488 commit e600253
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -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
MYSQL_PASSWORD=chemistrycafe # Replace with your MySQL password
2 changes: 1 addition & 1 deletion frontend/src/API/API_Interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ReactionSpeciesDto {
}

export interface User {
id: string;
id?: string;
username: string;
role: string;
email?: string | null;
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/RoleManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/pages/logIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -89,7 +88,6 @@ const LogIn = () => {
setUser(contextUser);
} else {
const newUser = {
id: "",
username: profileData.name,
email: profileData.email,
role: "unverified",
Expand All @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ INSERT IGNORE INTO users (id, username, role, email) VALUES
(UUID(), 'Joshua Hare', 'admin', '[email protected]'),
(UUID(), 'Nishka Mittal', 'admin', '[email protected]'),
(UUID(), 'Sydney Ferris', 'admin', '[email protected]'),
(UUID(), 'Britt Schiller', 'admin', '[email protected]'),
(UUID(), 'Kyle Shores', 'admin', '[email protected]');

-- Link users to mechanisms
Expand Down

0 comments on commit e600253

Please sign in to comment.