-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i have resolved login and signup page
- Loading branch information
1 parent
fd7bf76
commit 1400a37
Showing
10 changed files
with
258 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.