Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
landing, login, signup cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mirmirmirr committed Dec 10, 2024
1 parent 1d00e5f commit 0075749
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
7 changes: 0 additions & 7 deletions src/pages/Landing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export default function Landing() {
const { isDarkMode, toggleTheme } = useTheme();
const { isSmallScreen, isLargeScreen } = useScreenSize();

// document.cookie = 'code=' + code;
console.log(document.cookie);

const handelFocus = () => {
setIsFocused;
};

return (
<div
className={`z-50 relative flex flex-col items-center min-h-screen px-4 sm:px-8 ${
Expand Down
23 changes: 2 additions & 21 deletions src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ export default function Login() {
});
};

// const myCookie = document.cookie.split('; ').find(row => row.startsWith('email=')).split('=')[1];
// console.log(myCookie); // Outputs: 123

// if cookies exist, login the user already
console.log('getting cookies');
const cookies = document.cookie; // Get all cookies as a single string
const cookieObj = {};

Expand All @@ -99,14 +95,8 @@ export default function Login() {
}
});

console.log(cookieObj);

// const all_existing_cookies = getCookiesAsObject();
// console.log(all_existing_cookies);

const login_user = async () => {
var data = {};
console.log(document.cookie);

if (email.email == '' || passwordValues.password == '') {
handleError("Email + Password can't be empty.");
Expand All @@ -120,9 +110,6 @@ export default function Login() {
document.cookie = emailCookie;
document.cookie = passwordCookie;

// console.log(data);
console.log('login data? ', data);

try {
const response = await fetch('http://tomeeto.cs.rpi.edu:8000/login', {
method: 'POST',
Expand All @@ -134,9 +121,8 @@ export default function Login() {

if (response.ok) {
const result = await response.json();
// console.log('Login successful:', result);
console.log(result.message);
if (result.message.localeCompare('Login successful') === 0) {

if (result.message == 'Login successful') {
navigate('/dashboard');
} else {
handleError(result.message);
Expand All @@ -150,11 +136,6 @@ export default function Login() {
}
};

// if (cookieObj['login_email'] && cookieObj['login_password']) {
// console.log('We have login');
// login_user();
// }

return (
<div
className={`relative flex flex-col h-[100vh] p-4 overflow-hidden ${isDarkMode ? 'bg-[#3E505B]' : 'bg-[#F5F5F5]'}`}
Expand Down
6 changes: 0 additions & 6 deletions src/pages/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ function setCookie(email, password) {
const passwordCookie = `login_password=${encodeURIComponent(JSON.stringify(password))}; path=/;`;
document.cookie = emailCookie;
document.cookie = passwordCookie;
console.log('Cookies have been set.');
}

export default function Signup() {
const navigate = useNavigate();
// document.cookie = "username=John Doe";
console.log(document.cookie);

const { isDarkMode, toggleTheme } = useTheme();
const { isSmallScreen, isLargeScreen } = useScreenSize();
Expand Down Expand Up @@ -85,8 +82,6 @@ export default function Signup() {
};

const signupClick = async () => {
console.log(passwordValues.password);
console.log(email.email);
const data = {
email: email.email,
password: passwordValues.password,
Expand All @@ -106,7 +101,6 @@ export default function Signup() {
const result = await response.json();
if (result.message == 'User created') {
deleteAllCookies();
console.log('Login successful:', result);
setCookie(email.email, passwordValues.password);
navigate('/dashboard');
} else {
Expand Down

0 comments on commit 0075749

Please sign in to comment.