#Directus

In this episode we are going to implement login functionality to our Next.js and Directus app using NextAuth package.
We are also going to add user area page that will only be accessible to authenticated users. NextAuth is going to make this pretty simple for us to implement as you will see.
Code used in this video
bit.ly/3DXPfqD
You can support my work on Patreon
/ watchlearn
Follow me on Social Media
Github: github.com/ivandoric
Twitter: / ivan_doric

Пікірлер: 30

  • @amazingsly
    @amazingsly2 жыл бұрын

    Bro, you saved me a lot of time with this. It's my first day using directus, and you just answered all the questions I had. You earned a follow 😎

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Glad I could help, and thanks for the follow 😀

  • @mattd5419
    @mattd54192 жыл бұрын

    This is a very basic implementation. It doesn't take into consideration the access token expiration and refresh token expiration. Is there any tutorial that covers the auth refresh?

  • @torrentz4life392
    @torrentz4life392 Жыл бұрын

    Could you show how to update the token to keep the user logged in

  • @Soul_Kitchen67
    @Soul_Kitchen672 жыл бұрын

    Hello, This series is Fantastic. Thank you very much. I wanted to mention an issue I had with auth/login. I was getting a status: 403, Forbidden error when trying to login with the user created with the customer role. My admin user worked just fine. I was using insomnia to debug this problem and got an error, "invalid provider". So, I looked at the directus_users table. The Admin user has a "provider" set to "default", my customer role user did not have a provider. in sign-up.jsx I added "default" to the provider. It was an empty string. After doing this I am now able to authenticate. Thanks again for the great videos. [ directus 9.12.2 ]

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Could be that something has changed in the API, I assumed empty string IS the default. I will test this out when I upgrade Directus. Thanks for the info.

  • @zakur0hako

    @zakur0hako

    Жыл бұрын

    thank you for this comment

  • @eduardovargasleffaabrantes5148
    @eduardovargasleffaabrantes51487 ай бұрын

    Excelent!!

  • @regilearn2138
    @regilearn21382 жыл бұрын

    Hi ,would appreciate if you can do a series set,for how to do crud operation with all the form controls in react which include example like input /select /radio btn redio btn group /checkbox /date picker/time / file upload/ date range etc...,

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Probably not gonna happen. Sorry.

  • @yehudafruchter8582
    @yehudafruchter85822 жыл бұрын

    Doesn't the access token expire in 15 minutes or so? So the user is constantly logged out? I see you have the refresh token in the session, but this is never used. How would you implement that so the the access token is refreshed by using the refresh token?

  • @Civilizer1976

    @Civilizer1976

    3 ай бұрын

    Good afternoon Have you found a solution to this problem?

  • @alsherifkhalaf7385
    @alsherifkhalaf73852 жыл бұрын

    Very helpful

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Thanks 😀

  • @alsherifkhalaf7385
    @alsherifkhalaf73852 жыл бұрын

    If I stopped directus instance , the authentication status still "authenticated" I tried to console.log(status) on the user-area page it is "authenticated" even though I stopped directus . Why next-auth doesn't change status

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Well if you stopped Directus instance, then how would your app know that the user is authenticated or not? It would just show the last state. Users are not going to be magically logged off if Directus stops working.

  • @cro9364
    @cro93642 жыл бұрын

    what are the minimum server requirements to host both next js and directus on the same server?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    For my site I'm using Digital Ocean droplet with 2GB RAM/ 1Intel CPU / 50GB storage. It's about $12 per month. And it works fine. You can use my DO link to get $100 of credit for 3 months so you can play around with it: m.do.co/c/808fb4bb0039

  • @isakacan5669
    @isakacan56692 жыл бұрын

    hi sir, thanks for your videos. I want to ask you about paswordless/ magic link authentication in directus. Is there a way? I will send user and he clicks and after automatically login. no pasword needed.

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    According to the docs there is no such feature.

  • @iangithinji1452
    @iangithinji14523 ай бұрын

    Hi. How do I use strapi with clerk js?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 ай бұрын

    Read the docs probably.

  • @yspoon3500
    @yspoon35002 жыл бұрын

    Hello great video. What is the auth/login files ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Hey, I don't understand your question? Please elaborate.

  • @alsherifkhalaf7385
    @alsherifkhalaf73852 жыл бұрын

    How could we implement user roles with nextauth ? admin role and customer role ?

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    Not sure what you mean. Can you elaborate a bit? What are you trying to achieve?

  • @alsherifkhalaf7385

    @alsherifkhalaf7385

    2 жыл бұрын

    @@WatchandLearnTutorials actually i used Directus SDK , and your way of storing cookies in Strapi Course , This way is better than NextAuth way . It works now very fine Thank you for all your help and tutorials 😊

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    @@alsherifkhalaf7385 Glad you figured it out 😀

  • @Knorway56
    @Knorway562 жыл бұрын

    very helpful as always! I wouldn't try to use directus if you weren't here. by any chance, do you have a plan to make a video about implementing ouath using next auth and integrating with directus? I'm having trouble using oauth provider next auth has but directus does not. thank you for your content, cheers!

  • @WatchandLearnTutorials

    @WatchandLearnTutorials

    2 жыл бұрын

    I will not cover any more authentication in this series, but maybe this can help you: learndirectus.com/using-oauth-with-directus/