Skip to content

Commit

Permalink
i have resolved login and signup page
Browse files Browse the repository at this point in the history
  • Loading branch information
priyachau12 committed Oct 27, 2024
1 parent fd7bf76 commit 1400a37
Show file tree
Hide file tree
Showing 10 changed files with 258 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Backend/.env_sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MONGODB_URI=
PORT=8080
PORT=
CLOUD_NAME
CLOUD_API_KEY=
CLOUD_API_KEY_SECRET=
10 changes: 4 additions & 6 deletions Backend/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ export const loginUser = async (req, res) => {
}

// Respond with success message (add token logic if needed)
res
.status(200)
.json({
message: "Login successful",
user: { username: user.username, email: user.email },
});
res.status(200).json({
message: "Login successful",
user: { username: user.username, email: user.email },
});
} catch (error) {
res.status(500).json({ message: "Error logging in", error: error.message });
}
Expand Down
15 changes: 9 additions & 6 deletions Backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"cloudinary": "^2.5.0",
"cloudinary": "^1.21.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand Down
38 changes: 29 additions & 9 deletions Backend/utils/cloud.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
import { v2 as cloudinary } from 'cloudinary';
import { CloudinaryStorage } from 'multer-storage-cloudinary';
// import { v2 as cloudinary } from 'cloudinary';
// import { CloudinaryStorage } from 'multer-storage-cloudinary';

cloudinary.config({
// cloudinary.config({
// cloud_name: process.env.CLOUD_NAME,
// api_key: process.env.CLOUD_API_KEY,
// api_secret: process.env.CLOUD_API_KEY_SECRET
// });

// const storage = new CloudinaryStorage({
// cloudinary: cloudinary,
// params: {
// folder: 'wanderlust_dev',
// allowed_formats: ["png", "jpg", "jpeg"]
// }
// });

// export { cloudinary, storage };
import cloudinary from "cloudinary";
import { CloudinaryStorage } from "multer-storage-cloudinary";

const { v2: cloudinaryV2 } = cloudinary;

cloudinaryV2.config({
cloud_name: process.env.CLOUD_NAME,
api_key: process.env.CLOUD_API_KEY,
api_secret: process.env.CLOUD_API_KEY_SECRET
api_secret: process.env.CLOUD_API_KEY_SECRET,
});

const storage = new CloudinaryStorage({
cloudinary: cloudinary,
cloudinary: cloudinaryV2,
params: {
folder: 'wanderlust_dev',
allowed_formats: ["png", "jpg", "jpeg"]
}
folder: "wanderlust_dev",
allowed_formats: ["png", "jpg", "jpeg"],
},
});

export { cloudinary, storage };
export { cloudinaryV2 as cloudinary, storage };
13 changes: 6 additions & 7 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,31 @@ import "./App.css";
import Publish from "./pages/Publish";

// import Footer from "./components/Footer";
import Settings from './pages/settings';
import Settings from "./pages/settings";

import LandingPage from "./pages/LandingPage"; // Ensure this path is correct

import Signup from "./pages/SignUp";


import Login from "./pages/Login";

function App() {
return (
<Router>
<Navbar />
<div className="body-content">
<Routes>
<Route path="/" element={<LandingPage/>} />
<Route path="/" element={<LandingPage />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/posts" element={<Publish />} />
<Route path="/analytics" element={<Analytics />} />
<Route path="/contributors" element={<Contributors />} />
<Route path="/settings" element={<Settings/>} />
<Route path="/signup" element={< Signup/>} />
<Route path="/settings" element={<Settings />} />
<Route path="/signup" element={<Signup />} />
<Route path="/login" element={<Login />} />
</Routes>
</div>
</Router>
);
}

export default App;

8 changes: 4 additions & 4 deletions src/components/BasicNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "../pages/LandingPage.css";
const BasicNavbar = () => {
return (
<div className="landing-container">
<nav className="navbar" id="navbarr">
<div className="logo">
{/* <nav className="navbar" id="navbarr"> */}
{/* <div className="logo">
<img src="\is14Logo.png" alt="Logo" />
</div>
</div> */}
{/* <div className="nav-links">
<button className="btn-login">Login</button>
<button className="btn-signup">Sign Up</button>
Expand All @@ -25,7 +25,7 @@ const BasicNavbar = () => {
</Link>
</div>
</div>
</nav>
{/* </nav> */}
</div>
);
};
Expand Down
74 changes: 27 additions & 47 deletions src/pages/LandingPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,47 @@ body {
}

.landing-container {
height: auto;
display: flex;
border-radius: 5px;
flex-direction: column;
align-items: center;
justify-content: space-between;
background-color: #f7f7f7;
}
display: flex;
justify-content: flex-end; /* Aligns content to the right end */
padding: 0.2rem; /* Adds some spacing around the navbar */
/* background-color: #ec2222; */
border-radius: 5px;
border-radius: 5px;

.navbar {
width: 100%;
display: flex;
/* justify-content: space-between; */
background-color: #4a90e2;
max-height:40px;
}
}

#navbarr{
justify-content: space-between;
}

.logo img {
position: absolute;
height: 40px;
width: auto;
padding-left: 8px;
}

.nav-links {
margin-top: 2px;
display: flex;
gap: 15px;
margin-right: 35px;
}

.btn-login,
.btn-signup,
.btn-get-started {
padding: 10px 20px;
border: none;
cursor: pointer;
font-size: 16px;
border-radius: 5px;
transition: background 0.3s ease;
}
.nav-links {
display: flex;
gap: 1rem; /* Adds spacing between the buttons */

.btn-login {
}

.btn-login, .btn-signup {
width: 110px;
padding: 0.5rem 1rem;
font-size: 1rem;
cursor: pointer;
border: none;
background-color: #2563eb !important; /* Adjust color as needed */
color: white !important;
border-radius: 5px;
transition: background-color 0.3s;
}
/* .btn-login {
background-color: white;
color: #4a90e2;
}
.btn-signup {
background-color: #ffffff;
color: #4a90e2;
}
} */

.btn-get-started {
/* .btn-get-started {
background-color: #ff5e5e;
color: white;
font-size: 18px;
}
} */

.btn-login:hover,
.btn-signup:hover,
Expand Down
80 changes: 80 additions & 0 deletions src/pages/Login.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import axios from "axios";
import "./login.css"; // Add your CSS file
import BasicNavbar from "../components/BasicNavbar";

const Login = () => {
const navigate = useNavigate();
const [formData, setFormData] = useState({
email: "",
password: "",
});
const [error, setError] = useState("");

// Handle input changes
const handleChange = (e) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};

// Handle login form submission
const handleSubmit = async (e) => {
e.preventDefault();
const { email, password } = formData;

try {
const response = await axios.post("http://localhost:5000/api/users/login", {
email,
password,
});

if (response.data.message === "Login successful") {
// Navigate to the home/dashboard page upon successful login
navigate("/dashboard");
} else {
setError(response.data.message);
}
} catch (err) {
setError("Login failed. Please check your credentials and try again.");
}
};

return (
<div className="login-container">
<BasicNavbar />
<div className="login-form-container">
<h2>Login to Your Account</h2>
{error && <p className="error-message">{error}</p>}
<form onSubmit={handleSubmit} className="login-form">
<input
type="email"
name="email"
placeholder="Email"
value={formData.email}
onChange={handleChange}
required
/>
<input
type="password"
name="password"
placeholder="Password"
value={formData.password}
onChange={handleChange}
required
/>
<button type="submit" className="btn-login-submit">
Login
</button>
</form>
<p>
Don't have an account?{" "}
<Link to="/signup" className="signup-link">
Sign Up
</Link>
</p>
</div>
</div>
);
};

export default Login;
Loading

0 comments on commit 1400a37

Please sign in to comment.