MERN Authentication Tutorial #10 - Making a useSignup Hook

Поделиться
HTML-код
  • Опубликовано: 28 июл 2022
  • In this MERN auth lesson, you'll create a custom, reusable React hook that we can use to sign new users up to the application.
    ⭐⭐ Get the full course now (without ads) on the Net Ninja Pro site:
    netninja.dev/p/mern-auth-tuto...
    ⭐⭐ Get access to all free & PREMIUM courses on Net Ninja Pro:
    net-ninja-pro.teachable.com/p...
    🐱‍💻 Access the course files on GitHub:
    github.com/iamshaunjp/MERN-Au...
    🐱‍💻 MERN Stack Tutorial:
    On Net Ninja Pro - • Figma for Web Developers
    On RUclips - • MERN Stack Tutorial #1...
    🐱‍💻 React Tutorial:
    On Net Ninja Pro - codinginpublic.dev/projects/p...
    On RUclips - • Full React Tutorial #1...
    🔥🔥🔥 Other resources:
    VS Code - code.visualstudio.com/
    MongoDB Atlas - code.visualstudio.com/

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

  • @davidasiegbu2646
    @davidasiegbu2646 Год назад +7

    I get your notifications and I'm like this guy is out of this world. You're my man! Thanks

  • @Yata-
    @Yata- Год назад +3

    This current course completely improve my hook and context approch, thank's .

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

      You're very welcome!

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

    Awesome work mate! Love your efforts! ❤❤❤❤

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

    i'm so lucky to have found your channel online, i hope you post the next video today, thank you very much

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

      Thanks for your support :)

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

    I'm loving this series. Thanks dude ♥

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

      Glad to hear it! :) thanks Lyes

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

    Great course🔝🔝🔝🔝🔝 I hope the third part of the series involves refreshtokens!! 🎉🎉🎉🎉🎉🎉

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

    AAAAAAAAAAAAAAWESOME TUTORIAL ! Thnx a lot Shaun !

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

    Another reason why I prefer express-session over JWT--the credentials are automatically stored in a cookie 😊

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

    great lesson 👍

  • @GabrielGasp
    @GabrielGasp Год назад +9

    Why did you choose to store the user session in local storage? Wouldn't cookies be a better place?

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

      i wonder this too

    • @iganic7574
      @iganic7574 7 месяцев назад

      it is little complicated to pass cookie

  • @kodieivie
    @kodieivie Год назад +5

    Show us a video of your 1 million subscribers award from RUclips when you get it! I think you were at 25k subscribers when I started watching your tutorials. Your the best teacher on RUclips. Thanks for everything bro! Do you think you'll do a modern css course? I'm lost on all the different updates and what systems to use now..

    • @NetNinja
      @NetNinja  Год назад +2

      hey, thanks for sticking with me all this time :). I will share my award when I get it! Also, I will probably do a big modern HTML/CSS course on udemy at some point later in the year (hopefully!).

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

    would love to see this video redone with react query :)

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

    Thank you for the video! At the end you mentioned that you will check local storage to see if it already has the user. Is that a good way to see if user is already logged in? What if user does not let you write to local storage? What is a better way to keep track if user is already logged in?

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

    Hi!! Awesome work! Can you please make video on react monorepo?

  • @quastionable
    @quastionable 2 месяца назад

    Great series! I only wonder if locally storing the token keeps it safe from XSS attacks?

  • @andromilk2634
    @andromilk2634 3 месяца назад +1

    Two questions : I was under the impression that when we consumed our context, we could only do so from certain components which were being provided with. But here I have noticed we are consuming a context (useAuthContext) inside a custom hook? So I assume the idea that we must consume our context within a component being provided with this context is not always the case? (since the custom hook useSignup is not being provided with unless I'm missing something ...) Second question : how long does information stay inside the local storage? Thank you!

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

    Awesome 👏🏻

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

    Question: Will the button ever appear disabled? Doesn't the signup function always return the value of isLoading to be false?

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

    Bro can you please create a tutorial on webhook api implementation. Like how razorpay and stripe is providing payment event's to the webhook subscriber

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

    Awesome video +++++++++++++++++++ 🙂

  • @matthewanderson2959
    @matthewanderson2959 3 месяца назад

    how are you seeing the authcontext state in the console?

  • @Anteater23
    @Anteater23 14 дней назад

    Since the sign-in logic doesn't utilise any React hooks, should the logic not be stored inside a utility function instead of a hook?

  • @sameerp6272
    @sameerp6272 7 месяцев назад

    It is not updating the error and isloading at first time. It is updating the prev state after second click

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

    is react context is really necessary?

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

    Im getting "All fields must be filled" as my error message instead of "Email already in use"

    • @MrThundrchunky
      @MrThundrchunky 10 месяцев назад +3

      Fixed it: Typo
      const response = await fetch('/api/user/signup', {
      method: 'POST',
      headers: {'Content-Type': 'application/json'}, //this was 'Context-Type' instead of 'Content-Type'
      body: JSON.stringify({ email, password })
      Check your spelling

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

    thanks

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

      You're welcome dude!

  • @krish4659
    @krish4659 2 месяца назад

    I forgot status(400) in signup page and response.ok evaluated to true and i was not getting error even though i made error. please check those lines in case youare gettign the same error. it will save you one hour

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

    is it safe and is it standard industry practice to store token inside localStorage?

    • @nsrc9583
      @nsrc9583 Год назад +4

      It is definitely not safe and not standard practice. Those tokens should be kept as httpOnly cookies (i.e., disappear once the application's process terminates).

  • @fridayknight1387
    @fridayknight1387 Год назад +2

    Hi.
    I am watching your mern authentication playlist and am really enjoying it.
    but in this video i could not understand the functionality of isLoading variable. can you please explain that to me?
    thanks in advance :)

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

      This method is mainly used in asynchronous fetches. Fetching some data from a server takes some time, therefore, you create this state and tell your code to set setLoading to true until the data is fully fetched. And until it is fully fetched, you can tell the browser to show, for example, LOADING THE DATA. PLEASE WAIT text. And when setLoading is false, this text disappears. Here he used it to disable using the signup button, because, when you write an email in the input button and submit it, it should first compare if the email exists in the server data or not. If the data is not fully fetched, it cannot compare it.

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

      @@alimirhashimli2727 got it. Thanks a lot!

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

      @@alimirhashimli2727 Question: Will the button ever appear disabled? Doesn't the signup function always return the value of isLoading to be false?

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

      Please reply to my question🙃@@alimirhashimli2727

    • @andromilk2634
      @andromilk2634 3 месяца назад

      @@ibrahim525 It doesn't appear disabled in this case because I think the process is too fast for us to notice it being disabled/the css is not appearing different when it becomes disabled. Also, the moment you make the function call to signup, setIsLoading is set to True until the process terminates, which then setIsLoading is set to False, whether the process was a success or a failure because in both cases this particular process ended its job. I'm a beginner though.

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

    Has anyone come across this error "cannot destructure property 'signup' of............ Because it is undefined" ? Please help!!!!!

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

      You need to look up the signup object that you are trying to destructure. Destructuring only works if the property exists on the object if the object is null or undefined you are going to get this error. Look into where is the object signup coming from and check whether it is null or undefined.

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

    😍😍🔥

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

    I just bought the course and I have nothing. The videos ain't showing, the github is empty ? What this is all about ?

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

    Can someone please tell me were to find the source code. I am having a poblem with signing up and I get this error "User.signup is not a function"

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

    😍

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

    First :)

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

    1. Failed to load resource: the server responded with a status of 404 (Not Found) api/user/signup:1
    2. Uncaught (in promise) SyntaxError: Unexpected token '

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

      ruclips.net/video/PNtFSVU-YTI/видео.html it solved same error for me

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

    POST ..../api/user/signup 404 (Not Found)
    Uncaught (in promise) SyntaxError: Unexpected end of JSON input

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

      did you ever figure out this problem? If so, what did you do to fix it? I have the same issue.

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

      can you show your code

    • @patrickcarlomiranda941
      @patrickcarlomiranda941 Год назад +2

      same issue have you fixed it?

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

      same issue here

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

      Make sure that the json object that you are trying to send on the server side is inside the object guys.
      body: JSON.stringify({email, password})