#10 Adding User Authentication | Build a Complete App with GraphQL, Node.js, MongoDB and React.js

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

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

  • @sudhanshumarimganti4694
    @sudhanshumarimganti4694 4 года назад +3

    Postman now supports GraphQL queries! Its awesome! Thanks for the tutoarial.

  • @alextjn
    @alextjn 5 лет назад +8

    Great work, Max.
    However, I want to point out that express-graphql can parse request's body according to its content-type, so the body parser is unnecessary. With that gone, you can send application/graphql request using postman, and copy & paste the query/mutation directly from graphiql.

  • @richardcasey4146
    @richardcasey4146 4 года назад +4

    Great tutorials!
    FYI - Starting in version 7.2, Postman lets you create your POST body using syntax just like graphiql.

  • @TheMakdeniz
    @TheMakdeniz 4 года назад +1

    This Guy Rocks !! My source of nodeJs knowledge and videos are open to everyone just incredible.

  • @HarshalHirve555
    @HarshalHirve555 5 лет назад +1

    Hey Max, thank you for this quick upload. What a new year gift we have. Happy to see this video on 1 Jan

    • @academind
      @academind  5 лет назад

      Great to read that you like the video Harshal, happy new year :)

  • @me_yt
    @me_yt 4 года назад

    Hi, I am from Vietnam, I thank you very much for the Mongodb and Graphql series.
    Thank you very much.

  • @elvissam1401
    @elvissam1401 5 лет назад +3

    Hi Maximilian, excellent series. Happy 2019, keep the good work ¡.

    • @academind
      @academind  5 лет назад +1

      Thank you Esam, I'll try my best to do so! Happy new year also to you :)

  • @SkitchAle
    @SkitchAle 5 лет назад +4

    I recently discovered a REST client called "Insomnia". You can write graphQL queries like in GraphiQL, but it has all the elements like headers, authentication, etc. like Postman.
    I really recommend it. There is a version for linux, windows and mac OS.

    • @yavuzkoca8352
      @yavuzkoca8352 5 лет назад

      Agreed. There is also another app which is called "GraphQL Playground" does the same thing as you suggested.

    • @geooogle
      @geooogle 5 лет назад

      thank you!

  • @renon3359
    @renon3359 5 лет назад

    Now I know how I can create a backend with nodejs, graphql and mongodb. Superb work Max.

  • @Mental1993
    @Mental1993 4 года назад +1

    Postman has added a GraphQL option inside the Body tab. So it's a bit easier to write the queries/mutations. Of course, auto completion is not supported, as Postman has no idea about our project

  • @ahmetozdemir2207
    @ahmetozdemir2207 5 лет назад

    Great job! These videos should be watched way more! Keep up good work!

  • @allaheadflank
    @allaheadflank 5 лет назад +1

    Great series, Max. Enjoyed your React Native and Mongo courses through Udemy, btw. Hope you will do more RN and GraphQL. Maybe even some data visualization as well:) Happy New Year!

    • @academind
      @academind  5 лет назад

      Thanks so much for your great feedback and your support here and on Udemy! We'll see what the new year brings :)

  • @jesusarciniega8510
    @jesusarciniega8510 5 лет назад

    This course was so helpful, thanks!!, the explanation is fast and clear, and to the point.

    • @academind
      @academind  5 лет назад

      So happy to read that Jesus, thank you very much!

  • @ashutoshpanda4336
    @ashutoshpanda4336 5 лет назад +16

    Hey Max.... Please add this section how to upload photos and documents with nodejs and react and the reset of password if the user forget his/her password with nodejs and react

    • @ashutoshpanda4336
      @ashutoshpanda4336 5 лет назад +1

      Sending message can be made with socket.io check it out.... I've done end to end message passing from server to client and client to server.... No idea in between clients..... Message passing is quite heavy to understand

    • @acommunistdwarf
      @acommunistdwarf 5 лет назад

      Password Reset - One idea would be to create a temporary json web token that allows a user access to the password reset mutation, then you somehow send this to the email informed (I say somehow because I never did email with nodejs). Since GraphQL seems to only work with POST, you may have to think a way to create a link with that JWT to use in the request for the password reset mutation (You can create a Get route on Express that only purpose is to grab the token given as parameter and package it in a Post request). On the GraphQL side this is trivial, if the token is valid, you allow user to go ahead and reset the password, otherwise token either expired or was never valid and so throw an access denied.
      Uploading stuff - Not sure how this happens on GraphQL, it would be an interesting subject, but usually the way it's done with Express is to have static routes for GETing this files and then have the location stored in and passed around by GraphQL.

    • @ashutoshpanda4336
      @ashutoshpanda4336 5 лет назад +1

      @@acommunistdwarf I'll be honest.... I know the process the way you explained is really nice.... I really appreciate it but I've tried several times.... But didn't work for me... That is y asked..... I m really grateful for your descriptive answer... I used jwt token created a unique one send it to client mail dn reset function but some how I managed to screw Them up😪😪😪

    • @acommunistdwarf
      @acommunistdwarf 5 лет назад +1

      @@ashutoshpanda4336 yeah ... I really hope he takes on the items you mentioned because they are quite interesting and happen in tons of different applications. The suggestion is more a brainstorm in an attempt of having something to try if Max and folks on Academind don't take on the subject.
      I haven't watched the next videos yet, but I would assume he will tackle more the frontend side, which is fundamental for these two items you mention. As far as I can imagine, there is no off the shelf solution for this on GraphQL or Express.

  • @bossbhai4650
    @bossbhai4650 5 лет назад +59

    From Germany, We have SAP, Audi, FC Bayern Munich, and we have Max- All legendry Stuff.

    • @haimarazy
      @haimarazy 5 лет назад +1

      "Made in Germany" is the gold standard! Greetings from New York. Thanks for a wonderful series - it's very powerful and valuable.

    • @mabengga98
      @mabengga98 4 года назад +1

      Kurzgesagt, DW

  • @javascriptwar9525
    @javascriptwar9525 3 года назад

    sir your videos helps a lot ..☺🙏❤ from India

  • @hutterr
    @hutterr 5 лет назад +2

    Hey Max,
    Can you make more videos about user auth? In front-end with react js and apollo/graphql, how can we use this for logging in?

  • @GifCoDigital
    @GifCoDigital 5 лет назад

    Great video Max! This is actually a lot easier than trying to use Passport.js (which i JUST got finished doing) when only using json web tokens. Looks like I got some refactoring to do! :)

    • @academind
      @academind  5 лет назад +1

      Thank you, great to read that you like the video!

  • @baolyhong6140
    @baolyhong6140 4 года назад

    this is the coolest tutor I have ever seen. Thank for this reality skill

  • @bossbhai4650
    @bossbhai4650 5 лет назад +2

    hOW LONG IS THE COURSE Max- Thanks. Awesome Legendry Work.

    • @academind
      @academind  5 лет назад

      I'm still recording the videos so it's difficult to say at the moment. It will be a longer series though ;)

  • @techguru151
    @techguru151 5 лет назад +2

    Thanks a lot for sharing so much knowledge with us.

  • @mr2nikom
    @mr2nikom 5 лет назад

    Hi Max, Your tutorial is so great , I am totally stunned...........

  • @yoavostrinsky5172
    @yoavostrinsky5172 5 лет назад

    Hi Max! This series is really good! I'm not sure what ahead but can you show the process of deployment such an API to AWS API gateway or Google firebase functions? I think the devops part and some CI/CD for such API is very important.

  • @alejandrovelazco356
    @alejandrovelazco356 5 лет назад +8

    hey I have the problem that the req.get ("Authorization") always returns me undefined, does anyone know what it can be?

    • @cyberb4ss
      @cyberb4ss 4 года назад +1

      I ended up using req.headers.authorization instead

    • @clementvanstaen
      @clementvanstaen 4 года назад

      Same problem as Alejandro, and the "req.headers.authorization" fix does not work either (also undefined).

    • @clementvanstaen
      @clementvanstaen 4 года назад

      I take it back, I just add a typo in my code ::facepalm::

  • @arjunnarayanan9485
    @arjunnarayanan9485 4 года назад

    This has helped me so much! Thanks a lot Max :)

  • @maximos118
    @maximos118 4 года назад

    Hi Max, do you have a video for implementing refresh tokens with this middleware?

  • @rammar0606
    @rammar0606 5 лет назад

    Hey Max, Is there any specific reason to use `login` as Query rather than a Mutation? Many examples I have seen online used as a Mutation. Can you help me understand?

  • @lapocabri
    @lapocabri 4 года назад

    Thank you so much for making things clear and understandable.

  • @suseendharlal7176
    @suseendharlal7176 4 года назад

    There is this extension named ModHeader for chrome. Super easy to add header.Not takes more than 2 sec to send header

  • @cehson
    @cehson 5 лет назад +1

    Awesome tutorial, loving it !

  • @eugenemusebe4963
    @eugenemusebe4963 5 лет назад

    Am grateful for the content Max.

  • @awesomejs
    @awesomejs 5 лет назад +3

    Lots of love for you.. Thank's

  • @khandoor7228
    @khandoor7228 5 лет назад

    thanks Max great job, not simple by any means but you did a great job of explaining. I wonder how much research you have to do to make a 30 minute video???

    • @academind
      @academind  5 лет назад

      Very happy to read that Khan, thank you very much! It depends on the video and on the topic to be honest, but as I prepare the entire project and not a single video it's hard to name a number here.

  • @sanskaarpatni9137
    @sanskaarpatni9137 4 года назад

    Max thanks a lot for this amazing series! and for all other courses here and on Udemy! Is there a way we can donate even if it is a small amountt!!

  • @yazer79
    @yazer79 3 года назад

    Max, what are the cons of making my own auth vs using auth service?

  • @woife0705
    @woife0705 5 лет назад

    What about socket.io connections? do they have to be authenticated for every event they emit? Or is it ok to do this only during creation of the connection? What is the best practice to handle the token on client side? Is it save to store it in localstorage? What about the socket.io? Is it save to try to authenticate a existing token from the localstorage on creating the connection?

  •  5 лет назад

    MAx, you are awesome. Thanks for sharing the knowledge.

    • @academind
      @academind  5 лет назад +1

      Thanks so much for your awesome comment Diógenes, this really means a lot to me!

  • @alexmc814
    @alexmc814 5 лет назад

    Excellent series!! Could anyone tell how to make authentication to not drop every time on page reload?

  • @parrou3
    @parrou3 5 лет назад

    Hi guys, as per new ES6 syntax improvement, we can use "const user = await User.findOne({email}) " instead of ({email:email}) since both sides are the same :)

  • @DailyTravel
    @DailyTravel 5 лет назад

    Thank you for your best lecture videos!

    • @academind
      @academind  5 лет назад

      Thank YOU for this awesome feedback!

  • @kamaubrian7857
    @kamaubrian7857 5 лет назад

    Thanks Max!, Awesome as always

  • @shameekagarwal4872
    @shameekagarwal4872 4 года назад

    i understood postman + graphql but isnt there a better way using graphiql etc?

  • @mariezelenkova9743
    @mariezelenkova9743 3 года назад

    To save a little bit of the code, in JavaScript, an empty string would be false so no need to write:
    if (!token || token === "") {
    // some code
    },
    this would be enough:
    if (!token) {
    // some code
    }

  • @satyakibose8402
    @satyakibose8402 3 года назад

    Need help, while testing in postman, I am having "Unauthenticated". And in VS code also getting error: "JsonWebTokenError: invalid signature"

  • @mdelclaro
    @mdelclaro 5 лет назад

    You can use Insomnia instead of Postman for testing

  • @Bytes-Of-Love
    @Bytes-Of-Love 5 лет назад

    How we can restrict data based on the role of the user? Like for Employee, return small data set and for Manager return larger data set?

  • @kaurdeep4659
    @kaurdeep4659 4 года назад

    hello max, can you please also make a video to do node js passport local authentication with graphQL?

  • @ankitbhanderi2424
    @ankitbhanderi2424 5 лет назад

    Thanks for the series.

    • @bolte9519
      @bolte9519 5 лет назад

      You mean the serious....

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt 5 лет назад

    Thank u for this awesome video and I am waiting for next video

    • @academind
      @academind  5 лет назад

      Thank YOU for your great feedback and for your support Abhishek! The next part will be released this week.

  • @ceskmcfran
    @ceskmcfran 5 лет назад +1

    This fucking guy is a god

  • @marwansalem76
    @marwansalem76 3 года назад

    I got error in POSTMAN :
    "errors": [
    {
    "message": "Must provide query string."
    }
    ]
    Kindly let me know how to solve it!
    Thanks!

  • @jeremy1l
    @jeremy1l 5 лет назад +1

    Nice tutorial

  • @kadekeqw23
    @kadekeqw23 5 лет назад

    Just amazing, thank you.

    • @academind
      @academind  5 лет назад

      Thank YOU for your comment!

  • @hit3894
    @hit3894 3 года назад

    Great serious

  • @abdelrhmanshokr7546
    @abdelrhmanshokr7546 3 года назад

    thanks for the tutorial it really helped however when I run it it always fails when comparing I mean it always gets isEqual to false can you help ? can anyone help ?

  • @vzsshadow3141
    @vzsshadow3141 5 лет назад

    i like this video because i was curios how you wll do the auth with graphql :)
    btw !token and token ==='' is allways same because empty string is falsy :) 18:25

  • @Cesar-vx5vp
    @Cesar-vx5vp 5 лет назад

    Excelent!

  • @Softkkey
    @Softkkey 4 года назад

    Hello, is there any good video or resource to make an single Auth for two different websites and activate the cors for the two front end? Any recommendation would be great. Thank you beforehand
    Kind regards

    • @Softkkey
      @Softkkey 4 года назад

      And the other is using Apollo Graphql

  • @АндрейСмирнов-ш1о
    @АндрейСмирнов-ш1о 5 лет назад

    Is it possible for user to add in request field isAuth which will be equal to true and bypass protection?

  • @singhvimlesh
    @singhvimlesh 4 года назад

    Hello Sir can you help with project Node+Express+mongodb+Reactjs Login and registration form

  • @gosnooky
    @gosnooky 5 лет назад

    I like your serious

  • @VMzaVAS
    @VMzaVAS 5 лет назад

    Big tnx!

  • @AaronTheImposter
    @AaronTheImposter 5 лет назад

    Empty strings are falsy so checking !token already checks token === ''

  • @shahmirjadoon1322
    @shahmirjadoon1322 4 года назад

    Hello everyone!
    I am getting following error when try to execute mutation createEvent inside POSTMAN:
    "Must provide query string."
    Will someone kindly help?

    • @knightofcarrion7358
      @knightofcarrion7358 4 года назад

      I have the same error. Did you ever figure it out?
      Actually it gives me the error for the query too

  • @billy23910901
    @billy23910901 3 года назад

    how to fix this problem ??
    const authHeader = req.get('Authorization');
    ^
    TypeError: Cannot read property 'headers' of undefined
    plz!!!

    • @billy23910901
      @billy23910901 3 года назад

      how to fix this problem ??
      const authHeader = req.get('Authorization');
      ^
      TypeError: Cannot read property 'get' of undefined

  • @gncfhcnvc
    @gncfhcnvc 5 лет назад

    Saludos desde Chile

  • @himanshigupta9302
    @himanshigupta9302 3 года назад

    I'm getting error cannot return null for non nullable field rootquery. Login

  • @therko6
    @therko6 4 года назад

    If someone (like me) added in 'user.js' a flag 'select: false' to 'password' (to protect the field from being selected), You then have to add '.select("+password")' to 'findOne' function. Otherwise there is an error ""Illegal arguments: string, undefined"" because 'password' field won't be selected.
    user.js:
    const userSchema = new Schema({
    email: {
    type: String,
    required: true
    },
    password: {
    type: String,
    required: true,
    select: false //protection
    }
    ...
    auth.js:
    login: async ({ email, password }) => {
    try {
    const user = await User.findOne({ email: email }).select("+password"); //get user and password
    if (!user) {
    throw new Error("User does not exists");
    }
    ...

  • @satyakibose8402
    @satyakibose8402 3 года назад

    Why is it user.id and not user._id?

  • @hazrathshareef7166
    @hazrathshareef7166 5 лет назад

    OAthu with passport.js please

  • @duvanalonsogoezcorrea842
    @duvanalonsogoezcorrea842 4 года назад

    like

  • @rtorcato
    @rtorcato 5 лет назад

    The desktop app version of graphiql allows you to edit http headers. No need for postman. github.com/skevy/graphiql-app

    • @academind
      @academind  5 лет назад

      That is true. I also switched to Postman to already introduce how we structure the request body - we'll need that in the next parts.

    • @rtorcato
      @rtorcato 5 лет назад

      @@academind yes its good to know how to use graphql for postman as well. With apollo-server I'm getting a different graphiql. It has a section to edit headers as well. I'm not sure why apollo-server-express graphiql is different look.

  • @arjunsah8561
    @arjunsah8561 4 года назад

    Hi,
    The tutorial and code is outdated. Can you please update the code.