🔐 Learn How to Create a Secure Website with User Authentication using the MERN Stack! | Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024
  • In this comprehensive tutorial, I'll guide you through the process of building a feature-rich website with user authentication using the powerful MERN stack (MongoDB, Express.js, React, and Node.js). 🌐
    🔑 What You'll Learn:
    📌 Set up a MongoDB database to store user information securely.
    📌 Build a user-friendly front-end using React for seamless user interactions.
    📌 Create a robust back-end using Express.js and Node.js to handle user authentication.
    📌 Implement user sign up, login, and logout features with clear step-by-step instructions.
    📌 Enhance security with bcrypt: Learn how to hash user passwords to protect sensitive information.
    📌 Utilize JSON Web Tokens (JWT) for secure user sessions and authentication.
    📌 Best practices for handling errors, form validation, and user experience improvements.
    By the end of this tutorial, you'll have a fully functional website that incorporates industry-standard security practices to safeguard user data. Whether you're a beginner or an experienced developer, the easy-to-follow instructions in this video will empower you to create your own web applications with confidence.
    Twitter: / alancodes11
    GitHub Repo: github.com/Aar...
    #MERNStack #WebDevelopment #UserAuthentication #Bcrypt #JWT #Tutorial #FullStackDevelopment

ความคิดเห็น •

  • @AndreSilva-vu9db
    @AndreSilva-vu9db หลายเดือนก่อน

    Best video i've seen so far explaining the process of authentication, this was the one for me and i've seen a bunch of them! Keep the good work and thank you for sharing the knowledge!

  • @alchemist2579
    @alchemist2579 6 หลายเดือนก่อน

    There are so many comments that has already explained how great and rich this tutorial is and I'm adding on to them as I have watched the entire video and tried it out for myself.... this is by far the best tutorial that is rightly paced with explanation of every details that a beginner might look for . I had watched so many videos but they didn't help me to this extent . Sincerely, I thank you from the bottom of my heart !!!

    • @AlanCodes
      @AlanCodes  6 หลายเดือนก่อน +1

      @ruepic289 Thank you so much for the kind words! That really means a lot. I am super happy to hear that this video helped you tons! 🙂

  • @bereketg5609
    @bereketg5609 7 หลายเดือนก่อน

    This is not only authentication tutorial but also express😊 thanks man you explained everything

    • @AlanCodes
      @AlanCodes  7 หลายเดือนก่อน

      @bereketg5609 Thank you!!! 😊

  • @agntomega7220
    @agntomega7220 8 หลายเดือนก่อน

    I have seen many videos but they didn't teach us the last part of account section but now I understand the account section part with token and local storage thank you for creating this wonderful tutorial for us it really helped me a lot in understanding the MERN AUTH now I can easily implement this in all my projects ♥♥♥

    • @AlanCodes
      @AlanCodes  8 หลายเดือนก่อน

      @agntomega7220 I am sooo happy to hear that! Certain parts of MERN are a bit tricky to understand at first but once you get it, the possibilities for different projects are endless! Thank you so much for your awesome comment!! 😊

  • @clairebayoda8325
    @clairebayoda8325 3 หลายเดือนก่อน

    Thank you so much for this wonderful content, Alan! Looking forward for more content from you! 🙏

    • @AlanCodes
      @AlanCodes  3 หลายเดือนก่อน

      @clairebayoda8325 I really appreciate it! Thank you! I will try to get more out soon! 🙂

  • @sunithab2704
    @sunithab2704 ปีที่แล้ว +5

    On point tutorial. Thanks for explaining every step in detail

    • @opsingh861
      @opsingh861 9 หลายเดือนก่อน

      he implemented secured routing in it???

  • @kumar_sanjeevdutta1069
    @kumar_sanjeevdutta1069 ปีที่แล้ว +4

    Sweet and simple, thanks, I was not able to protect my page now I will try your technique

    • @kumar_sanjeevdutta1069
      @kumar_sanjeevdutta1069 ปีที่แล้ว

      You know what, it worked, really grateful to you, thanks, and if possible, please make a small mern project including redux, just core not readux thunk ❤❤❤❤

  • @byronloarte
    @byronloarte ปีที่แล้ว +1

    Excellent video my dear friend

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว +1

      @byronloarte973 Thank you! I really appreciate the feedback!

  • @BhanuPrakash-ql7qf
    @BhanuPrakash-ql7qf 7 หลายเดือนก่อน

    I saw lot of mern authentication videos but ur explanation video is very clear to understand... thanks a lot😊

  • @mjylove2
    @mjylove2 5 หลายเดือนก่อน

    Amazing ! Really loved the video!👍

    • @AlanCodes
      @AlanCodes  5 หลายเดือนก่อน

      @mjylove2 I am thrilled! Thank you so much!! 😊

  • @manojk-r2p
    @manojk-r2p 7 หลายเดือนก่อน

    thank you bro i watch numerber of vedios but your vedios gives me very clear cut pxplanation even though i dont know thamil im am from telugu state

  • @the-boss-98
    @the-boss-98 ปีที่แล้ว

    Better than most paid courses out there!

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @the-boss-98 Thank you so much! I really really appreciate it! 😊

  • @pramitsrivastava2579
    @pramitsrivastava2579 ปีที่แล้ว +1

    bro thank you so much for making a video in such an detailed manner I was struggling in how to authenticate the user but after watching this video I understood that how it's done .

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @pramitsrivastava2579 I'm super glad to hear that!! 🙂 You got this! Now that you understand how it's done, keep building that muscle memory, and everything else will be so much easier 🙌🏼

  • @majjisobhamadhuri9140
    @majjisobhamadhuri9140 ปีที่แล้ว

    Thank you so much I have seen so many vedios but I am not getting perfectly but this tutorial helps me a lot and got the exact output...kudoos to ur work😊

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @majjisobhamadhuri9140 I'm happy to hear that! And thank you! That's definitely why I decided to make videos. Keep at it! 😊

  • @kronos7455
    @kronos7455 10 หลายเดือนก่อน

    great way of explaining thing and making project .keep it up bro.create a movie rating app or food order app

  • @MUSE859
    @MUSE859 ปีที่แล้ว +1

    awesome tutorial thanks🙏

  • @azhara.2143
    @azhara.2143 ปีที่แล้ว

    Thank you, let's go learn MERN stack

  • @lucifer_bois
    @lucifer_bois 11 หลายเดือนก่อน +1

    Great❤🎉🎉

  • @Joey-Jets
    @Joey-Jets ปีที่แล้ว

    Really great tutorial. Btw what theme are you using, looks clean.

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @mojo382 Thank you so much! The theme I'm using is Monokai Pro Filter Spectrum

  • @greenball296
    @greenball296 หลายเดือนก่อน

    is it possible to use typescript for the code in node? if so, do we need to set it up or can we just touch server.tsx?

  • @baraiyasachin9166
    @baraiyasachin9166 9 หลายเดือนก่อน

    love from india 💗

    • @AlanCodes
      @AlanCodes  9 หลายเดือนก่อน

      @baraiyasachin9166 Thank You!!!

  • @starX7995
    @starX7995 ปีที่แล้ว

    really good for beginners bro❤‍🔥

  • @curtiss5982
    @curtiss5982 ปีที่แล้ว

    Great Video Man👏👏👏

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @curtiss5982 Thank you so much! I really appreciate it! 🙏🏼

  • @ruqayahn.k4645
    @ruqayahn.k4645 ปีที่แล้ว

    thank you very mach , very useful 🌹❤

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      Im super glad! 🙂

  • @ravindueshan2786
    @ravindueshan2786 11 หลายเดือนก่อน

    Thank you so much

  • @KarthikVijay-m6t
    @KarthikVijay-m6t 11 หลายเดือนก่อน

    do this method work in hosting platforms like vercel as i think localstorage wont work there

  • @kronos7455
    @kronos7455 10 หลายเดือนก่อน

    I have one issue,when I sign out it directly leads to a blank white page

  • @captain_11155
    @captain_11155 ปีที่แล้ว +1

    Hello bro thanks, but if user login and token will expire then how to protect the account then i mean there is always token in local storage until i clicked on signout. Please can u tell me how to protect or redirect users to login if token expired.

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว +1

      @captain_11155 Hey! Thats a very good question! I don't have physical code, but one thing you can try is in the app.js file, make a function that helps check if the token is expired, then you can add it inside of the protected route logic (inside the curly brackets). you can try putting it in here {isUserSignedIn && }. Make sure to change up the code. Hope this helps!

    • @captain_11155
      @captain_11155 ปีที่แล้ว

      @@AlanCodes ya I did already after punching the head to the code 🤯😅 but anyway thanks 👍

  • @alihassanhaji2830
    @alihassanhaji2830 ปีที่แล้ว +2

    This is the kind of videos we need in MERN stack, Thanks brother fr the big effort, I would you to add the implementation of password reset and nodemailer 🙏🙏🙏

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว +1

      @alihassanhaji2830 thank you so much!! My pleasure! Those were definitely some ideas I had for upcoming videos! 🙂

  • @captainash4714
    @captainash4714 ปีที่แล้ว

    Why at 51.02 we are comparing all the bycrypt passwords to that one user password , We were supposed to compare bycrypt password of that user with the original password of that user only?

    • @bhat_hazim
      @bhat_hazim ปีที่แล้ว

      We are comparing the password that has been recieved from body to the password that is being stored in db

  • @tarunlanka740
    @tarunlanka740 9 หลายเดือนก่อน

    Sir what to do if get "Error signing up " in postman

    • @AlanCodes
      @AlanCodes  9 หลายเดือนก่อน

      Hey @tarunlanka740 ! If your are receiving that 500 "Error signing up" error code, somethings you might want to double check are.
      1- Making sure the connection to your mongoDB is successful
      2 - Checking if the permissions in MongoDB allow you to readWriteAnyDatabase
      3- Double check your HandleRegister function to make sure the endpoint for the submitted form is being sent to /register
      4- In Postman, when you make a POST request to localhost:3001/register, make sure the "Body" tab is clicked, then "raw", then choose "json" and use format:
      {
      "email": "json@json.com",
      "username": "json",
      "password": "password"
      }
      Hope this helps!!

  • @jayadityag7670
    @jayadityag7670 11 หลายเดือนก่อน

    Awesome

  • @rashidshahriar7913
    @rashidshahriar7913 ปีที่แล้ว

    please create role based login system with mern stack

  • @valenciawalker6498
    @valenciawalker6498 7 หลายเดือนก่อน

    Thank you

  • @Pransshhh
    @Pransshhh ปีที่แล้ว

    Very good work Sir. Thank you. Please teach us how to use auth0 in next video

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @pranshuverma1645 Thank you! I'm not too familiar with auth0 but when I do get more familiarized with it , i'll def make a video!

    • @Pransshhh
      @Pransshhh ปีที่แล้ว

      @@AlanCodes Sure Sir

  • @ravindueshan2786
    @ravindueshan2786 11 หลายเดือนก่อน +1

    (node:28800) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
    (Use `node --trace-warnings ...` to show where the warning was created)
    node:events:492
    throw er; // Unhandled 'error' event
    ^
    how can i fix this error

    • @MARENO-vy4cx
      @MARENO-vy4cx 11 หลายเดือนก่อน

      i am also getting the same error. did u rectify it? if yes, tell me how did u do it?

    • @ravindueshan2786
      @ravindueshan2786 11 หลายเดือนก่อน

      @@MARENO-vy4cx yes ,remove useUnifiedTopolgy

    • @ravindueshan2786
      @ravindueshan2786 11 หลายเดือนก่อน

      @@MARENO-vy4cx remove the useUnifiedTopology

    • @yuvrajverma4318
      @yuvrajverma4318 10 หลายเดือนก่อน

      just remove the those lines. mine worked perfectly without those.

  • @MikiStec
    @MikiStec ปีที่แล้ว

    Your login is not working man. You only save "token=undefined", you do not send token to frontend and on frontend you do not check it at all.. I can also set manually in Dev Tools. I've already posted such comment but I do not see it here, did you just delete it? If I am wrong, please correct me, do not just delete my comment.. That's not the way to gain trust hm? I was not any rude, I even gave you a shout out how simple and useful your tutorial is, only it's not completed.

    • @AlanCodes
      @AlanCodes  ปีที่แล้ว

      @MikiStec Hey! Thank you for pointing it out. I will make sure to correct those errors in the future. I really appreciate you pointing it out! As far as your other comment goes, I haven't deleted any comments. Even if I make any mistakes, deleting comments won't help anyone who is trying to learn, especially if you are pointing out information that is super valuable and that will help others, and myself included. Thank you once again!

    • @MikiStec
      @MikiStec ปีที่แล้ว

      @@AlanCodes great. Your way of explaining and your simplified style is just brilliant, keep posting!

  • @abdulmuhsinbaksh8757
    @abdulmuhsinbaksh8757 8 หลายเดือนก่อน +1

    Hello, Apologies is this is a dumb question, but how does your JWT Token work here? like what does this line of code do: const token = jwt.sign({ userId: user._id }, SECRET_KEY, { expiresIn: '1hr' }), I dont see it being used in the frontend, so how is the token being used to protect?

    • @AlanCodes
      @AlanCodes  8 หลายเดือนก่อน +1

      Hi @abdulmuhsinbaksh8757 ! Its not a dumb question at all! In that line of code, we are using jwt to generate a token when a user successfully signs in with their username and password. The token is then attached or tied to the user's {user.id} or unique identifier, which was made for them at sign up. Then, in the backend server, the secret key helps validate the generated token to make sure the token is authentic. The token then is passed to your frontend, that way it can be stored in the browser for the signed in session. Lastly, we are setting the token to expire 'in 1hr', securing the session for automatically logging users out after 1 hour.
      Hope this helped!

    • @abdulmuhsinbaksh8757
      @abdulmuhsinbaksh8757 8 หลายเดือนก่อน +1

      @AlanCodes how is the token beings stored into the frontend?