MERN Stack: Advanced User Authentication & Authorization | Mern Authentication | MERN Stack Project

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024

Комментарии • 174

  • @droid8770
    @droid8770 Год назад +1

    I haven't seen the your full video but the "technologies will be used" overview gave a really great feel and I know that this is "actually" advanced

  • @WSBWallstreetBets
    @WSBWallstreetBets 2 года назад +11

    This is an amazing video and helped me out exactly with my project. Keep up the work, you've really taught me a lot.

    • @dhanasekare6384
      @dhanasekare6384 10 месяцев назад

      When I refresh the page the reference router the refresh token function throw an error like cookie.split the cookie is undefined

  • @shaamray-k6c
    @shaamray-k6c Год назад +2

    The way you are interacting with the project is so good, explaining each and one thing is very recommendable, hope you will bring much more projects soon

  • @TedWard
    @TedWard Год назад

    I have just gone completed this and it works great! I followed the video checked the app at same points, this allowed me to catch any self made errors as I went.
    This is one of best introductions to this topic I have found on the web which isn't behind a paywall! I have learnt a lot from this video and will be watching more from this channel!
    Thankyou!

  • @sarectua
    @sarectua 2 года назад +1

    Thank you for sharing your knowledge. I, perhaps for the first, fully understand the process of authentication as a self-learner. Many thanks!!

  • @dilanshanuka1838
    @dilanshanuka1838 8 месяцев назад +1

    Greate Course! 😍

  • @JJ-ot3ps
    @JJ-ot3ps 2 года назад

    wow this is the best mern auth out there! great work indian coders, I learned a lot especially cookier parser!

    • @JJ-ot3ps
      @JJ-ot3ps 2 года назад

      and just one minor suggestion is to add the admin auth too, and email confirmation for signup and password lost. Also good idea to use something like express validator package.

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Thanks for the suggestion, will look into it

    • @Ankit-bd9zp
      @Ankit-bd9zp Год назад

      Facing problem 'undefined'by logging to the console the COOKIES

    • @Ankit-bd9zp
      @Ankit-bd9zp Год назад

      Please hel

  • @TBDfilesLalit_kalyan
    @TBDfilesLalit_kalyan 2 года назад

    dhnyawad bhai ........bahot hi badiya kaam

  • @thaarik879
    @thaarik879 2 года назад +4

    wow. good and most wanted video. But i feel , in future videos pls do coding with ES6.

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Sure will do with ES6 in Nodejs. And we have upcoming projects on MERN too 😊

  • @ehteshamali5471
    @ehteshamali5471 2 года назад +10

    Please add forget password session in this part 2 by email confirmation

  • @Anushkai1
    @Anushkai1 8 месяцев назад

    Very Clear. Thank you

  • @jawadullah4685
    @jawadullah4685 2 года назад

    thank you yr seriously a lot of help from your toturials thank you so much

    • @IndianCoders
      @IndianCoders  2 года назад

      Thanks. Please support this channel by sharing on your social media.

  • @bibhasash7371
    @bibhasash7371 Год назад

    no we can use it with fetch also. in case of axios we can use withCredentials:true and in case of fetch we can use credential:'include'

  • @codingwala303
    @codingwala303 2 года назад +1

    Nice video from Karachi

  • @HAMZAALI-gd9cl
    @HAMZAALI-gd9cl 2 года назад

    Thanks for describing in such a great way!!!!
    I learnt a lot

  • @ksn425
    @ksn425 2 года назад +4

    after logged in successfully when i refresh page No routes matched location "/user" and can u help me how can i implement /config on sails js project (config/session.js) and how to remove or modify sails autogenerated cookie named sails.sid

  • @hamzabouyahya6657
    @hamzabouyahya6657 2 года назад +3

    when refreshing page and logging again there is an error which the user is undefined when verifying token in verifyToken function

  • @uboxtech
    @uboxtech Год назад

    mine vscode is not showing suggestions of mongo models, or the cookie part, how to fix it?

  • @jaikrishna3586
    @jaikrishna3586 2 года назад

    thankyou so much i really learned new thing today

    • @IndianCoders
      @IndianCoders  2 года назад

      Please support by sharing and subscribing

  • @snapytips
    @snapytips 2 года назад +1

    It's a good idea, but it just increases network requests. Is it possible to control the network request with this idea when dealing with production applications?
    💡

  • @upendrabhanushali6585
    @upendrabhanushali6585 11 месяцев назад

    Thank you for this

  • @syednoohu8692
    @syednoohu8692 Год назад

    I think better approach would be creating separate Refresh Token, Will you make one Video for us? Thanks a lot

  • @ithisrinu9593
    @ithisrinu9593 2 года назад +1

    I am happy to the name of you tube

  • @uv_codes
    @uv_codes Год назад +1

    If we just delete our req.cookies in refresh token handler, then how in this world we are supposed to get it in our verify token handler just after deleting it.

  • @saadsaleem4992
    @saadsaleem4992 2 года назад +5

    i am getting value of cookie undefined

  • @RahulKumar-vo1of
    @RahulKumar-vo1of 2 года назад +2

    Thank You so much for this amazing vedio

  • @mahendranath2504
    @mahendranath2504 Год назад

    nice thank you so much

  • @mashkoorahmed7255
    @mashkoorahmed7255 2 года назад

    good bro keep it up

  • @detro__x
    @detro__x 2 года назад +1

    Good one

  • @jawaderfani8743
    @jawaderfani8743 2 года назад +2

    Hey bro! I am not able to stay logged in after refreshing the page

    • @IndianCoders
      @IndianCoders  2 года назад

      Have u correctly followed the approach?

    • @IndianCoders
      @IndianCoders  2 года назад

      Please check with backend first and then try it on frontend

  • @sumanjha7590
    @sumanjha7590 2 года назад +1

    I am not able to stay logged in after refreshing page...and i have checked your code and it's behave the same

  • @try-b2k
    @try-b2k 3 месяца назад

    cookies are not being sent even the withCredentials are true in axios
    please provide any solution for this

  • @oreMilic
    @oreMilic Год назад +3

    code is not working it is getting (Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client) and token is not valid

    • @kanaramjangid8563
      @kanaramjangid8563 Месяц назад

      Bro just se your controllers and remove multiple return statements

  • @geekofia
    @geekofia Год назад

    1. same site has a default value of lax
    2. what's the point of using cookie-parser if you are accessing headers.cookie and splitting it using = as delim 😐 should have accessed cookies json object from req.cookies

  • @vijaykoladara8302
    @vijaykoladara8302 2 года назад +2

    how to protect routes in react ?you not covered yet

    • @IndianCoders
      @IndianCoders  2 года назад

      I've added it in the courses. As of now they are just conditional protected routes but you can implement it in another class and use that

  • @khantradingsniper6422
    @khantradingsniper6422 2 года назад +1

    Hi Sir,
    can you show us how to persist loginState after logging in on each refresh???
    Plzzzz
    Thank you in advance.

  • @chethankambi31
    @chethankambi31 2 года назад

    Good stuff, really helpful. If you could talk a bit slow it would be awesome. Thanks!

  • @jonaskhoza5075
    @jonaskhoza5075 2 года назад +1

    cookie not being set to the browser Application area yet it can be found in the response headers after login. Can you plz help with that

  • @Arunabh95
    @Arunabh95 2 года назад +1

    great bro

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Thank you♥️

    • @Arunabh95
      @Arunabh95 2 года назад

      @@IndianCoders completed just now ♥

  • @nishantmoolya
    @nishantmoolya 6 месяцев назад

    After deployment browser is not setting cookie what to do now

  • @OOC-03
    @OOC-03 Год назад

    thank you bro

  • @worldoframanan3358
    @worldoframanan3358 2 года назад

    wow thanks bro

  • @craftland587
    @craftland587 Год назад

    hello, i have learnt so much from your video, but will you please explain clearly about "provider" and "store"...

    • @Ajaykumarr89
      @Ajaykumarr89 Год назад +1

      are you talking about provider and store in redux ? to make the data of the store available to the entire components, we have to wrap our main component that wraps all other components inside the provider component and pass the store as a value to the provider component. while the store is a central part where we store our data that needs to be updated and it is available to the entire app.

  • @spreadtheloveglobally
    @spreadtheloveglobally Год назад

    Which key u used to import login, signup, welcome ???

  • @abhaypratap9898
    @abhaypratap9898 Год назад +1

    On refreshing the page after login I am getting logged out 🤕

    • @Lvtotravel
      @Lvtotravel 6 месяцев назад

      Because of redux reset the value of logged in need to persist using redux persist

  • @RazibAhmed-e9g
    @RazibAhmed-e9g 3 месяца назад

    if i do code with you then am i facing any problem as it is old content

  • @salihhasan9662
    @salihhasan9662 2 года назад +1

    in sing in if an account was already exit it will give an error and user will not know what is happened .!
    question: how to handle msg between backend and frontend

    • @IndianCoders
      @IndianCoders  2 года назад

      You can send messages from backend, but in the end we checked it with already logged in user. Please check again what's wrong

  • @kim92se64
    @kim92se64 2 года назад +1

    1 hour and 57 minutes watched

  • @dhanasekare6384
    @dhanasekare6384 10 месяцев назад +1

    When I refresh the page the reference router the refresh token function throw an error like cookie.split the cookie is undefined

  • @jkforsaken3866
    @jkforsaken3866 Год назад

    hey thanks for the amazing video! but after logging in, if i refresh the page it logs out automatically why so?

  • @HAMZAALI-gd9cl
    @HAMZAALI-gd9cl 2 года назад +2

    On signup token is not generated and throws error invalid token also showing this
    (Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client)

  • @JJ-ot3ps
    @JJ-ot3ps 2 года назад +1

    hi again! if I set the token expiration for 1 day, do I still need to do the refreshing token routes? I find that refreshing every 30 seconds is a bit too much burden on network request, I like the cookie idea, but refreshing route is a bit burden though for users, especially for ecommerce site, I mean people need to keep refreshing their webpage while shopping can be annoying, no?

    • @IndianCoders
      @IndianCoders  2 года назад +1

      You can check refreshing time for 1 hour or a day as well.

  • @anuragrajput5631
    @anuragrajput5631 8 месяцев назад

    will the user have to login again the next time he visits? or will it remain login for the next time as well.

  • @viditgoel2909
    @viditgoel2909 5 месяцев назад

    The jwt token get's verified everytime even after changing the token intentionally

  • @Ankit-bd9zp
    @Ankit-bd9zp Год назад

    Facing error 'undefined' by logging console to the COOKIE
    PLEASE HELP ME

  • @josecorrales9703
    @josecorrales9703 Год назад

    thanks Nikhil

  • @BCS_Mdadilkhan
    @BCS_Mdadilkhan 11 месяцев назад +1

    what happen when user refresh the page before 28 sec will the timer of setTimeout function will restart and then token has expired before hitting the refreshToken api.if token has expired before hitting the refresh token api then how u can get the id of user from the token and how u can get the details of the user without that id that uses getUser api??????

  • @gltcoder6800
    @gltcoder6800 Год назад

    do i have to write this axios. /refresh code on every page after login i mean i have multiple pages a complete dash board, so do i have to add it to all the pages?

  • @WSBWallstreetBets
    @WSBWallstreetBets 2 года назад +2

    I'm a bit confused on the token/cookies. I have it all set up, but if I want to go to another Route/Component - how do I get the user object to carry on? Whenever I go to a new URL, the cookie/token are gone? How do I access it across my app? I think I'm confused about some fundamentals here.

    • @WSBWallstreetBets
      @WSBWallstreetBets 2 года назад

      The goal is to allow a user to login, and from there they are shown the services available to them. And as they click a new page, it is rendered to show their info (i.e. Hello, Name).

    • @IndianCoders
      @IndianCoders  2 года назад

      It's already implemented there to move to a different components like welcome page.
      Maybe you are doing something wrong. Please check source code and see where it went wrong

    • @WSBWallstreetBets
      @WSBWallstreetBets 2 года назад

      @@IndianCoders So I figured it out. My question is - do I have to call the getUser on every component in order to fetch the user? And do I have to implement the refresh token on every component?

    • @Priya_Ruth
      @Priya_Ruth Год назад

      ​@@IndianCoders

  • @HAMZAALI-gd9cl
    @HAMZAALI-gd9cl 2 года назад

    can you please tell me what I need to do?????

  • @supratiksarkar1195
    @supratiksarkar1195 Год назад

    first time its working. again i try with new user signup, i dont know why it happens to me only, its not workig. postman says signup please. even when i copied everything correct, checked, re-checked, its not workign for me. i am leaving full stack, it not for me. goodbye

    • @IndianCoders
      @IndianCoders  Год назад

      Can you find code on GitHub to check if it works

  • @Short_and_Simple
    @Short_and_Simple Год назад

    getting cookie is 'undefined' error. Noit sure how to fix it

  • @suryaimmadisetty5252
    @suryaimmadisetty5252 6 месяцев назад

    does anybody had repo which is in this repo

  • @jothmart4023
    @jothmart4023 Год назад

    why did you delete the source code from GIT?

  • @voxuanhoa1166
    @voxuanhoa1166 Год назад

    after i login, i refresh , error occur, may be this is a bug, i want when i refresh, we still in user page

  • @itsnitinks
    @itsnitinks 2 года назад

    Im getting error while hashing illegal arguments ; number, string

  • @anjalishukla7650
    @anjalishukla7650 Год назад

    req.cookie is undefined why??this error

  • @ajaytiwari5243
    @ajaytiwari5243 2 года назад

    Sir please make a video on multiple user roles

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Coming with a major project

    • @ajaytiwari5243
      @ajaytiwari5243 2 года назад

      @@IndianCoders thank you so much sir 🙏

  • @houwayda9254
    @houwayda9254 2 года назад +1

    nice video but how fix this error please
    'ERR_HTTP_HEADERS_SENT'

    • @IndianCoders
      @IndianCoders  2 года назад

      Can you please share the full error and when you are getting this error and in backend or frontend?

    • @houwayda9254
      @houwayda9254 2 года назад

      @@IndianCoders in this part ( Creating Frontend - Adding Welcome User Page and Sending axios request with withCredentials property)

  • @syedsaadali420
    @syedsaadali420 9 месяцев назад +1

    Hi if you are looking this comment please reply to me or anyone can help its necessary I have followed your tutorial and make project everything is been fine and cool but problem is that when I logged in it display me user information but when I refresh that page all information gone I tried each and everything but nothing works, can you guide me which part of code I have to change to stop that behavior and user data remain in page even If I refresh The page

    • @doruktekel3438
      @doruktekel3438 4 месяца назад

      same

    • @syedsaadali420
      @syedsaadali420 4 месяца назад

      @@doruktekel3438 ahaha I am here for you, actually bro his technique and implementation is very poor that creates so much problems and plus he is not storing cookie properly with am mechanism of time duration, I will recommend you to instead of jwt, use express session technique with bcrypt library and when user sign in a session is been created for all necessary things you have governed user name..email or phone... And from that session you will display that in to user profile and it's easy to implement too.

  • @abhishekgouda4029
    @abhishekgouda4029 5 месяцев назад

    hey sir after login showing user not found can u send github source code link

    • @doruktekel3438
      @doruktekel3438 4 месяца назад +1

      bro he share source code , yon can change branch in github source code

  • @vanithb6630
    @vanithb6630 2 года назад

    sir, same step i have followed using next js. not working.

  • @MeduxaHD
    @MeduxaHD 2 года назад

    hey, its not working for me :( whats the packages i need to install?

    • @IndianCoders
      @IndianCoders  2 года назад

      Check package json file in GitHub branches

  • @nalcapital
    @nalcapital 2 года назад +1

    Please help me.Browser (postman) create two cookies : 1 for auth, other is "refreshToken" automatically. And split('=')[1] dont work because cookies have a two tokens. Google didnt help. How can I delete this "refreshToken"?

    • @IndianCoders
      @IndianCoders  2 года назад

      Hi. I think the problem is, before creating refresh token, make sure to check if cookies are already there for that ID. If it's there, delete that cookie's value and you can also clear that cookie from res.clearCookie() function. And then refresh token will work fine. And for the auth, you can restart the server and make a fresh auth request but before sending request make sure you are not already in welcome page because from there it'll send request with use-effect. You can move to login route again and check.
      Check if this solution works. And I'll upload the source code for this tutorial today itself . And let me know if it's fixed. 😊

    • @nalcapital
      @nalcapital 2 года назад

      @@IndianCoders thx Man, I will try

    • @nalcapital
      @nalcapital 2 года назад +1

      @@IndianCoders Used res_clearCookie('refreshToken') once. It solved my problem

    • @IndianCoders
      @IndianCoders  2 года назад +1

      @@nalcapital great 👍😃

  • @hulkbruce7992
    @hulkbruce7992 2 года назад

    Bro I have issues with login route in backend can u post the code in your GitHub??

  • @AuxiliaryOfficial
    @AuxiliaryOfficial 2 года назад +2

    would be best if you give the source code please ;(

  • @worldclasscode1847
    @worldclasscode1847 2 года назад +1

    Great Video! Where is the source code?

  • @alanlevy1986
    @alanlevy1986 2 года назад

    i wish you had the source code, much easy to follow up

  • @Richard-wg4lu
    @Richard-wg4lu Год назад

    The concept is good but after refreshing the page, why the refreshToken is not working why the prevToken is expired after refreshing .. is it because the setInterval() reset everytime we refresh the page?. Any solution?

    • @IndianCoders
      @IndianCoders  Год назад

      Looking into it

    • @Richard-wg4lu
      @Richard-wg4lu Год назад

      @@IndianCoders Aye why did you delete my comment in that other guys reply 😂. Bruh dont worry about it, everybody makes mistakes.

    • @Richard-wg4lu
      @Richard-wg4lu Год назад

      const VerifyToken = async (req, res, next) => {
      const cookies = req.headers.cookie;
      if (!cookies) {
      return res.status(401).json({ message: 'Error not found' });
      }

      const token = cookies.split('=')[1];
      JWT.verify(String(token), process.env.SECRECT_key, (err, decoded) => {
      if (err) {
      return res.status(400).json({ message: 'Invalid Token' });
      }
      // Doing this because what if they refresh after login because setInterval Reset
      res.clearCookie(decoded.id)
      req.cookies[decoded.id] = '';
      const token = JWT.sign({ id: decoded.id }, process.env.SECRECT_key, { expiresIn: "35s" })
      // console.log('REGenerated Token
      ', token)
      res.cookie(String(decoded.id), token, {
      path: '/',
      expires: new Date(Date.now() + 1000 * 35),
      httpOnly: true,
      sameSite: 'lax'
      });
      // Doing this because if they refresh after login because setInterval Reset

      req.userId = decoded.id;
      next();
      });
      };
      This works if i regenerate token in VerifyToken again for the refresh problem. Idk Whether this is a good approach.

  • @rafemulla6972
    @rafemulla6972 2 года назад

    error handler TypeError: Cannot read property 'split' of undefined ??
    how can I solve that issue ?

    • @IndianCoders
      @IndianCoders  2 года назад

      Maybe the token is incorrectly set. Check in source code

    • @rafemulla6972
      @rafemulla6972 2 года назад +2

      @@IndianCoders it's worked on postMan, but on react it's dosnt set the cookie

  • @AnujKumar-dz3vi
    @AnujKumar-dz3vi 2 года назад

    i have gotten error "can not read undefiend property 'user' at about.js" deploying the site

    • @IndianCoders
      @IndianCoders  2 года назад

      What's the error?

    • @AnujKumar-dz3vi
      @AnujKumar-dz3vi 2 года назад

      @@IndianCoders can not read undefined property 'user' at about.js

    • @AnujKumar-dz3vi
      @AnujKumar-dz3vi 2 года назад

      @@IndianCoders sir please make a video on how to deploy that site

  • @nithinraj342
    @nithinraj342 Год назад

    where is the source code

  • @rishikeshsingh7182
    @rishikeshsingh7182 2 года назад +1

    source code is empty

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Check branches

    • @rishikeshsingh7182
      @rishikeshsingh7182 2 года назад

      @@IndianCoders thankyou for your contribution to this community this is very helpful

  • @DevendraSingh-oq2re
    @DevendraSingh-oq2re 2 года назад +1

    Giving Empty github repo is not called giving source code . Please don't make us fool nobody is dumb bro !!!!! , and Please share the code it's a humble request.

    • @IndianCoders
      @IndianCoders  2 года назад +1

      Have u checked branches 🙃

    • @DevendraSingh-oq2re
      @DevendraSingh-oq2re 2 года назад

      @@IndianCoders Yeah got it. I never saw someone putting it like that way. Anyway Thanks a lot mate !!

  • @AnujKumar-dz3vi
    @AnujKumar-dz3vi 2 года назад

    Hello sir please deploy this website i have so many errors at deploying time

  • @syednoohu8692
    @syednoohu8692 Год назад

    Great tut! but code pls? github empty

  • @indian_gaurav_8648
    @indian_gaurav_8648 Год назад

    ye video achanak kaha gayab hogai thi

    • @IndianCoders
      @IndianCoders  Год назад

      Hmm because I am about to push another one with more features such as admin, reset password etc

    • @indian_gaurav_8648
      @indian_gaurav_8648 Год назад

      @@IndianCoders to kabtk ajayegi

  • @GnarMarv2
    @GnarMarv2 2 года назад

    Hey is this React or React Native?

  • @kuhubhatnagar2877
    @kuhubhatnagar2877 2 года назад

    the time i started using cookies in the project, postman stopped giving any output. It kept loading and loading for about 2 hrs. What must be the error here?

    • @IndianCoders
      @IndianCoders  2 года назад

      Check error in console. And let me know

    • @kuhubhatnagar2877
      @kuhubhatnagar2877 2 года назад

      @@IndianCoders it worked thank you so much for this tutorial

  • @oscardeb747
    @oscardeb747 2 года назад

    Can I get the source code please?

    • @IndianCoders
      @IndianCoders  2 года назад

      Yes. It's there in description.

    • @oscardeb747
      @oscardeb747 2 года назад

      @@IndianCoders no its not in the description,,, please check again.

  • @AnujKumar-dz3vi
    @AnujKumar-dz3vi 2 года назад

    please deploy this project

  • @shaikhsimran3227
    @shaikhsimran3227 Год назад

    Don't watch this doesn't work I spent lot of time and it was waste

    • @IndianCoders
      @IndianCoders  Год назад

      it works well. are you stuck somewhere?

  • @faisalqureshi7094
    @faisalqureshi7094 Год назад

    If you are not getting cookies in node js . set sameSite = none and scure = true in res.cookie
    res.cookie(String(user._id), token, {
    path: '/',
    expires: new Date(Date.now() + 1000 * 30),
    httpOnly: true,
    sameSite: 'none',
    secure: true
    })

  • @Krishmusic26
    @Krishmusic26 Год назад

    how to solve this error-:
    Cannot read properties of undefined (reading 'data')
    TypeError: Cannot read properties of undefined (reading 'data')
    at sednRequest (localhost:3000/main.b32a4075083886843b25.hot-update.js:42:28)