User Management in MERN: Create, Authenticate, and Administer Your MERN E-Commerce Store
ฝัง
- เผยแพร่เมื่อ 5 ก.ย. 2024
- In this pivotal episode of our MERN e-commerce development course, we delve deep into the world of user management. Master the art of user authentication, authorization as an admin, and gain the skills to create, read, update, and delete users on both the frontend and backend of your project.
🚀 What You'll Master:
User Authentication: Learn to implement secure user authentication, ensuring only authorized individuals access your e-commerce platform.
Admin Privileges: Gain insights into user role management, giving you the power to oversee and control your empire.
Create, Read, Update, Delete (CRUD): Discover how to perform CRUD operations, empowering you to manage user data seamlessly.
Frontend Magic: We'll guide you through crafting an intuitive and visually appealing user interface for your website, enhancing the user experience.
Backend Brilliance: Dive into backend development, where you'll create the logic to handle user data and maintain your empire's integrity.
By the end of this video, you'll have the knowledge and skills needed to take complete control of user management for your e-commerce project, all while ensuring your platform is secure and user-friendly.
Don't miss this opportunity to enhance your development skills and take a step closer to building a successful e-commerce empire. Join us and embark on this thrilling journey through MERN stack user management!
Follow Me On 👇
TH-cam: / @huxnwebdev
GitHub: github.com/hux...
Twitter: / huxnwebdev
Instagram: ❌
Complete Project Playlist👇
th-cam.com/video/PRpTY5LS95M/w-d-xo.html&pp=gAQBiAQB
Source Code 👇
github.com/HuXn-WebDev/MERN-E-Commerce-Store
Hi great learning thnks, And I am facing issue in getUsers ---- UserList.jsx:16 Error: No data found at `state.api`. Did you forget to add the reducer to the store?
Below details e.apiR. DidDevToolget to add the reducer to the store? from redux toolkit "getUsers(undefined)"
reducerPath:"(state, action) => combinedReducer(resetApiState.match(action) ? void 0 : state, action)"
status:"rejected"
Insane🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉
00:01 back end
1:18:24 frontend navbar
1:35:20 rtk query
🤜
Bro you are special one in this TH-cam community
pls continue this humbleness and support to the community.
And your work is extra ordinary thank you.
Big respect
Thank you so much buddy for your amazing comment🥂
The biggest project in TH-cam
My bro 🤝
While building the frontend if you could keep the original website in another tab for for reference it would be helpful. Like you can tell that I am currently making this sidebar or navbar to achieve certain features or something , for that we have to write this block of code. Thank you.
Brother I just started your playlist, so far it's really good
I think the user deletion feature should be changed to hide the user instead. As I understand it, that's a soft-delete technique, and we shouldn't completely delete a user. Thank you for providing such great content. Wish you happy weekend
I appericate your suggestion but can you also tell what we're gonna do with the user info when we specificly wanna delete the account entirely? ( happy weekend )
@@huxnwebdev I haven't fully grasped the entire project yet. I simply think that if a user wants to recover their account, we can restore it for them. Additionally, this can help prevent issues such as viewing order details related to deleted users, which may occasionally lead to errors. That's what I think.
@@huxnwebdev You can use express-async-handler instead of custom handler? can you explain the reason behind using custom middleware over package?
@@iamjabeed I did install the express-async-handler package in the video (just in case) but then i decided to use custom error handler, creating a custom middleware gives you more control over the error-handling process. You can customize the error handling logic to fit your specific needs, You can integrate other error-handling mechanisms and logging as per your project's requirements, and all n all it helps you understand how error handling in Express works, making it a valuable learning experience.
On the other hand, using (express-async-handler) can save time and make your code more concise, especially for smaller projects or when you prefer a quick and easy way to handle asynchronous errors.
your content is awesome brother huge welcome and keep doing this all the best bro
Thank you so much buddy 🤝
Let me finish this before this playlist gets paid only 🗿☝️
You are an Insane Developer 🔥❤✨
haha Thank you 🤝
😍😍😍The content you provide is really good, I love it.
Thanks buddy, means a lot 🥂
can we not update the username and email of the current admin like if i have signed in as a admin and i am trying to edit my name than it is giving me error this is the error (syntaxError: Unexpected token 'N', "Not author"... is not valid JSON)
2:31:52 For some reason whenever I click the arrow instead of it showing up next to the username, it shows up on top of the sidebar, any fixes?
bro i am facing dificulties with flowbite like it is showing that cannot find module but i have installed it will it be okay if i do not use it ?
I haven't finished the entire video yet but the loginUser controller does not have a try catch block or any error handling in the case of user logging in that doesn't exist or wrong password. Maybe you get to that later. Great videos bro!
Good course 👍👍
Thanks buddy ❤️
Awesome work man⚡
Thank you very much! 🤝
hello sir, We really appreciate you
I'm glad my content was helpful for you buddy 🤝
can someone tell which font he is using in vscode.
any specific reason for not using axios? would have been simpler in my opinion
Appreciate it 🎉
🤜🤜
are you using a dark mode extension for the whole website or you've provided dark colour to the body
.js file when import to .jsx error happen
I got an error with "not authorized, no token" instead of "not authorized as an admin" at 48:55. I did exactly the same thing like you did in coding. But it doesn't work when it comes to get all users. Can anyone please help?
Hi, I've made specific code commits for each video in my GitHub repository for this project. You can find the commit related to "User Management" and compare it to your code to identify any discrepancies in the backend.
I wish i could help but unfortunately i can't ask you to send me your repo link because of many reasons which i can't discuss.
Hey I am having the same problem and also my IsAdmin is not changing to true.....Is it working for you now ???
the problem is
secure: process.env.NODE_ENV != "development" inside generateToken function in createToken.js
that's because cookies can only be sent when the request is secure and safe which is HTTPS and outside of that will not work. so the solution is removing that
My brother ❤
My Brother 🥂
Amazing thanks #Huxn WebDev kindly do also a full course Flutter and Dart plus real world projects...and how to setUp machine(computer) min requirement for Flutter and Dart dev....?
Hello, awesome tutorial, im loveing it. I have a problem with the login, i can login but the page dont redirect lo the home page, i have to refresh the page and then im inside the user logged
useEffect(() =>{
if (userInfo) {
navigate('/');
}
}, [navigate, redirect, userInfo]);
const submitHandler = async (e) => {
e.preventDefault();
try {
const res = await login({email, password}).unwrap();
dispatch(setCredentials({...res}));
} catch (error) {
toast.error(error?.data?.message || error.message)
}
};
i also tried this but it doesnt work
useEffect(() =>{
if (userInfo) {
navigate(redirect);
}
}, [navigate, redirect, userInfo]);
the page throw this error :
(intermediate value).getItem is not a function
What is total time you have taken to complete this project bro?
Alex is so cool 😂😂
Brother you can do this in a much simpler way.But why you make it difficult like for api redux thunk is most used
hi huxn i followed every step but at 2:22:41 when you click on sign-in i am getting userinfo on console-log but my page is not redirecting at all and tried to match my code with your github code everthing was fine infact there no error in my console log please help
same problem
@@nezuko7517 actually I solved it there was a typo error which was not so easy to discover
I'm encountering error Typo error in safe buffer ,can you help me please @@vedpandere898
@@vedpandere898 how did you do???
@@nezuko7517 have got where the error is...
I stuck in 3 hours just because I didn't know that I have to install mongoDB, I though that this playlist already say all setups we need
You said you didn't have MongoDB installed, which suggests you might not be ready for this project because if you were you would've already installed mongoDB in your machine. If you don't know MongoDB yet, it's better to finish my whole MERN course before trying this project. That way, you'll be better prepared.
Hi sir, which browser are you using?
Its opera gx
i am getting undefined in jwt cookie authorize
Push your code to GitHub and send me the link on any of my socials.
I can't proceed beyond 49:05 because postman replied "not authorized as an admin" when I pushed 'send' button after logging in with my admin account.
Push your code to github and send me the link on any of my socials.
@@huxnwebdevActually, I coded along with you. All of my codes are the same as your code, Sir. I think authorizeAdmin is the problem because both req.user and req.user.isAdmin are false.
You just made me clone my repo and install all the dependecies, I just checked and everything is working on my side, idk what's wrong with your code, as i said push your code to github and send me the link so that i can see what you did wrong.
@@huxnwebdev const authorizeAdmin = asyncHandler(async (req, res, next) => {
const adminUser = await User.findOne(req.isAdmin);
if (adminUser === true) {
next();
} else {
res.status(401).send("Not authorized as an admin.");
}
}); I changed this and I can finally get all users passing through authorizeAdmin. I keep coding with you! Thank you so much. If I have some problems, I will keep asking you. Thank you again.
@@huxnwebdevThank you for your support. Your videos and tutorials help me understand MERN stack so much.
hi @huxnwebdev
I have problem i am login as an Orange and when i click update i see SyntaxError: Unexpected token 'N', "Not author"... is not valid JSON and when i check console shows me this:
Failed to load resource: the server responded with a status of 401 (Unauthorized) Not authorized as an admin.
Please help!
probably because the user account that is logged in is not an admin