❤Please Support me by subscribing to my channel 👉🏻www.youtube.com/@sakuradev?sub_confirmation=1
@lakshitha_sandamal3 ай бұрын
i'm already subscribed sir 😇🤗🙃. and thanks your all tutorial videos 🙏. god bless you sir
@qunther Жыл бұрын
A masterclass. Your video is the most complete on KZbin. Most of them always skip an important step, so their video become useless. You've made everything from A to Z, thanks a thousand time 🙏
@SakuraDev Жыл бұрын
Thank you so much for your nice words 💞. I'm really happy that you like it 😊
@larrymcfarlane6202 Жыл бұрын
Not an easy transition to the NextJS section if you're following along with code, but if you can figure it out, hands down one of the best tutorials out there for refresh tokens for both client and server.
@SakuraDev Жыл бұрын
Thanks 👍
@arieldebarros11 ай бұрын
I'm also havind difficulties transitioning to the NextJS. It doesn't even build! How did you manage to follow along the tutorial?
@CoreCave Жыл бұрын
Thanks!
@SakuraDev Жыл бұрын
Thanks a lot for your support. ❤❤🌷🌷
@bhavikshah58697 ай бұрын
This was insanely helpful for me. Thank you!
@SakuraDev7 ай бұрын
Thank you so much for your support 🙏💓
@tonyfrenzy3 ай бұрын
I can assure you, this is one of the best explanations on implementing authentication in Nest/NextJs
@SakuraDev3 ай бұрын
Thank you so much for your support 💖🙏
@_codesan Жыл бұрын
Terima kasih.
@SakuraDev Жыл бұрын
Thank you so much for your support ❤️🙏
@rahmatsulistio Жыл бұрын
wow... this is the video I've been waiting for, thanks man
@SakuraDev Жыл бұрын
Hope you enjoyed it!
@hc4382 Жыл бұрын
Very good tutorial, perfect u said a lot of things can not find in others tutorials, especially how to refresh the accessToken silently.
@SakuraDev Жыл бұрын
Thanks, I am glad you like it 🙏
@SakuraDev Жыл бұрын
@@michaeltrembovler8301 thanks 🙏 it was for the mic settings. I have fixed it.
@vinception77710 ай бұрын
Hey thank you so much, you made this very clear to me, I'm using session and not JWT, but your content is currently helping me a ton to setup all this stuff ☺
@huskeluv5 ай бұрын
I was looking for a tutorial, not for a mayor! (brazilian meme to show how grateful I was for find this!)
@SakuraDev5 ай бұрын
So, I hope you like it 😉
@PattySpicy Жыл бұрын
I will also learn this Tutorial, The combination in this tutorial is awesome ! I see how amazing things NestJS can do ! I am still waiting for NestJS Postgres TypeORM, JWT Token, Key Cloak authentication, user role and OTP login !oo
@SakuraDev Жыл бұрын
Hey, I am really glad you like it. Since I have not worked with Key Cloak, I need to do some research and find out how we can integrate it with node.js frameworks.
@PattySpicy Жыл бұрын
@@SakuraDev I appreciated your replied, I like how you teach a lot. it simple and easy to understand for beginner, but I have given some intermediate task that not much good tutorial available form y usecase, you're kind of my last hope lol
@dionisidoksani771811 ай бұрын
Amazing video tutorial. Everything explained and detailed to its core perfection!
@SakuraDev11 ай бұрын
Thank you so much 🙏🙏🙏🙏
@owaissurferaccount4 ай бұрын
Thank you so much, NextJS Auth explained well with external BE... amazing
@SakuraDev4 ай бұрын
I'm glad you found it helpful! Combining it with an external backend adds a layer of complexity, but understanding the core concepts is crucial.
@АлександрМерный-м1ч9 ай бұрын
good job bro ! A most comprehansive tutorial I've seen.
@SakuraDev9 ай бұрын
Thanks 🙏🙏🙏🙏
@esquilo_atomico8 ай бұрын
🤗Obrigado amigo! Você é um amigo!
@SakuraDev8 ай бұрын
Thank you so much. It means a lot to me 🙏❤️
@caresbruh11 ай бұрын
This is far better than those paid courses out there 😍
@SakuraDev11 ай бұрын
I am really glad that you liked it 😊
@tarek.k.hallak Жыл бұрын
Thanks a lot 🙏🏻🙏🏻 You have made it super clear.. and you managed to talk about i guess everything that related to authentication and authorization unlike other youtubers
@SakuraDev Жыл бұрын
Thanks 🙏🙏
@jaleisme Жыл бұрын
You're the best, Brother! Hope you have a wonderful life ahead of you!
@SakuraDev Жыл бұрын
Thanks for your nice words 💖. I hope you do well ❤️🩹
@jpcc1223 Жыл бұрын
i'm wordless, you helped me alot. thank you so much for posting this content!!!!
@SakuraDev Жыл бұрын
Thanks 🙏🙏. I am really happy it was helpful for you
@rayzzer332 ай бұрын
Thank you, a very clear and useful tuto ❤
@SakuraDev2 ай бұрын
Thank you so much 🙏. The newer version of this video will be uploaded next Monday which covers a lot more new features.
@borooLIVE5 ай бұрын
just thank you! You achieve new spectator!
@SakuraDev5 ай бұрын
Thanks for visiting and welcome to my channel 👋
@eugenetsymbal217011 ай бұрын
Thanks for the great tutorial. I just want to make one clarification for those who are not familiar with JWT authorization. The refresh token must be implemented in such a way that it cannot be used more than once. And if an malicious user gets your refresh token and uses it, you will notice it immediately when you try to use it on your side. But in your implementation, if I understand correctly, the refresh token is reusable, since it is hardly possible to implement it without saving the token value itself to the database.
@floviskabanda80446 ай бұрын
that is realy what i was looking for a while... thank you a lot
@SakuraDev6 ай бұрын
Glad I could help!
@khangmach017 ай бұрын
Thank u, one of underrated awesome content out here.
@SakuraDev7 ай бұрын
Glad you think so!
@marcusvinicius189111 ай бұрын
thank you so much! A real masterclass.
@SakuraDev11 ай бұрын
You're very welcome!
@gendev1105 Жыл бұрын
Great Content ! Keep Up The Good Work !
@SakuraDev Жыл бұрын
Thanks, you too! I am really glad You liked it.
@gendev1105 Жыл бұрын
@@SakuraDev I am already watching it for a second Time ! keep up the Good Work ! Great Content
@esquilo_atomico8 ай бұрын
coming here again, very useful video
@SakuraDev8 ай бұрын
Thank you so much 🙏🙏🙏
@MihajaItrasMihajaItras Жыл бұрын
thanks bro you are the best teacher!
@SakuraDev Жыл бұрын
Thanks 🙏👍, I am really glad to hear that from you ☺️
@denvudd4492 Жыл бұрын
Thank you so much friend it's been really useful tutorial!
@SakuraDev Жыл бұрын
I am really happy it was helpful for you😃🌹
@jaychoi8821 Жыл бұрын
This is .... damn! so goooood. thank you a lot ....couldn't help subscribing :)
@SakuraDev Жыл бұрын
Thanks 👍
@_codesan Жыл бұрын
Cant wait the next video
@SakuraDev Жыл бұрын
I am really happy that you like my video. In the next video I will refactor the nest.js project and use Drizzle ORM for that. I hope you will like it.
@ekimcemulger8101 Жыл бұрын
You are awesome as always :) ! Thank you.
@SakuraDev Жыл бұрын
Thanks 😃🌹
@sithumdasantha3147 Жыл бұрын
Thank you so much for the video
@SakuraDev Жыл бұрын
Thanks 👍🌹🙏
@angHoangAnhQuan-kb9yq10 ай бұрын
Hi, I have a question. The refresh token is only use when you reload the page or re-login. What's happen if the access token is expired then you call an API without reload the page? I'm so confused, please help me awnser this. Thank you!
@kusy30034Ай бұрын
Usually you're making a call for a refresh token before current access token expired
@pain2theworld6124 ай бұрын
In CreateUserProfile section you can also replace id with +id so it will convert the string to number
@SakuraDev4 ай бұрын
Thanks for the heads up!
@sksabbirhossain268611 ай бұрын
best video ever. love from Bangladesh.😍😍
@SakuraDev11 ай бұрын
❤️❤️
@rongcody32925 ай бұрын
Greate video , Thank you for sharing 🥰
@SakuraDev5 ай бұрын
Thanks a lot 🙏. You can also check out my latest Nestjs course playlist.
@carlosbarbier240111 ай бұрын
Amazing tutorial. Thanks a million
@SakuraDev11 ай бұрын
You're very welcome!
@allone258 Жыл бұрын
Great job sir 👏
@SakuraDev Жыл бұрын
Many thanks
@eriksund13698 ай бұрын
At 1:23:44 when you refresh it still has the username in the sessions (top right). How is a good way to have all of this updated as well when the accessToken expires?
@CoreCave Жыл бұрын
Nice effort. we have learned a lot
@SakuraDev Жыл бұрын
Thank you! I'm glad you learned a lot.
@abdalrhmanalmarakeby58136 ай бұрын
Thank you very much. This video was very helpful.
@SakuraDev6 ай бұрын
Really glad it was helpful
@BK-fk4gf11 ай бұрын
Definitely great!
@SakuraDev11 ай бұрын
🌷🌷🙏
@any_account-b6x Жыл бұрын
valuable tutorial! thank you
@SakuraDev Жыл бұрын
You're very welcome! I'm thrilled to hear that you found the tutorial valuable. If you ever need more assistance or have questions, feel free to reach out. Happy learning!
@any_account-b6x Жыл бұрын
@@SakuraDev yes i have a question🙂 i followed your tutorial to the end and i pass the accessToken to the authorization header in the fetch() method. but its annoying to set the authorization header over and over again. do you know if we could set the authorization header on every request with the help of the middleware? i tried to implement it this way but i failed 😄
@SakuraDev Жыл бұрын
@@any_account-b6x hi, if you're using client components, you can use axios interceptors. For server components, I recommend create a reusable fetchData func that only get API url. And then, in there call fetch func and set authorization header. And anywhere you need to fetch, just call fetchData func.
@lucasdindault41711 ай бұрын
Hey ! Nice video! I've just got one question: how do you ensure that, on the Next side, the user is automatically logged out when their token expires?
@Everydaycono Жыл бұрын
Thank you so much this video is awesome I have a question. at the 1:41:30 mark in the video, there's a question about how to hide the session information that appears in the network tab every time you access the web, specifically the "GET /api/auth/session" request, which shows session details such as user and backendTokens. Is there a way to conceal this information? The reason for wanting to hide it is that the token values are being exposed. Do you have any advice on this matter?
@SakuraDev Жыл бұрын
Yes, but it isn't a big deal because if the user is not authenticated, it is not shown in the network tab. Thanks 👍
@Everydaycono Жыл бұрын
@@SakuraDev thank you!
@ngaji_it Жыл бұрын
@@SakuraDev How about XSS issue?
@angHoangAnhQuan-kb9yq10 ай бұрын
Hi thanks for the video, I have a question, at the 47:17 mark in the video, I have an error that "Parameter 'req' implicitly has an 'any' type." so it's really an any type or something other type? I'm fixing it by add ''@Request() req: any" but do you have any better idea?
@SoccerIQChallenge90714 күн бұрын
Hi, thanks for your work! I have a question: how can I synchronize the main backend tokens with the token created by NextAuth?
@SakuraDev5 күн бұрын
Hi you just need to provide the same expiration time for both tokens
@tarek.k.hallak11 ай бұрын
With this implementation if i provided a correct token i can Access any endpoint with all the ID's.. that means that i can access any profile i want if i have its id
@SakuraDev11 ай бұрын
That's right, we should have done some extra validation for that, for example we can extract the id of the user from the access token and authorize the user to get the profile if it is its own profile.
@ozdadev7 ай бұрын
In your components you have manually added the Bearer totken which is not a easily maintainable approach, what if refresh token in invalid?
@hooyah8 ай бұрын
thanks for the video 🙏🙏❤❤, I was curious how to handle role base authorization, at 1:25:07, you created middleware only for those who have sessions, but what if I have a dashboard for users and a dashboard for admin or maybe a dashboard for sellers? I like the way you solved the refresh token problem. I usually use axios interceptors like you taught me in the past.
@skkabirislam5934 Жыл бұрын
Amazing ❤❤❤
@SakuraDev Жыл бұрын
Thanks 😊👍
@roktimashraful2085 Жыл бұрын
Sir , your tutorial was amazing, i have an one question, my question is when you try to refresh the token at that point is it possible to clear the session with sign-out and redirect to the login page?
@attilabeli_com Жыл бұрын
Point on. Just tested: in case of invalidated refresh token, the user session remains valid. I could even navigate to routes assumed protected.
@roktimashraful2085 Жыл бұрын
Yeaa , and even i con't call logout function in server component also ,
@ernestsdane351011 ай бұрын
That is the nature of JWT auth. There is no real way to honor the user's request to sign out (to invalidate a JWT token) because of this the users are going to stay logged in until the access token expires. In order to solve this issue, you are going to have to look to session based authentication (also known as cookie-based authentication). Because you can save the session tokens in the database, it is very easy to de-authenticate the users - just delete the session token or mark it as invalid.
@sulavbaral9972 Жыл бұрын
Hey can you make a video with both google and oauth provider like google with capabilities of storing both of these in a database
@ego_dubovik Жыл бұрын
Hey, Thanks it's realy cool tutorial!
@SakuraDev Жыл бұрын
Thanks, 🙏 I am really glad you like it
@noureddein804410 ай бұрын
Thanks alot for the amazing videio but now what will happend if the refreshToken expired? How I can force the user to logout ? That the main issue i faced when i tried many times to implement the NextAuth.
@jeesan485 Жыл бұрын
Thank you so much. your tutorials helped me on my own project. A project idea if its ok, users triggers long running job from client side seeing live status of the said job. Something that can handle lot of users kicking off long running job/script etc
@SakuraDev Жыл бұрын
Thanks. Typically, Node.js is not good on long CPU intensive jobs. although, its performance on I/O intensive jobs is great. so it is better to use microservice architecture for this kind of jobs.
@jeesan485 Жыл бұрын
@@SakuraDev interesting, do you know any example repo i can look at? my main goal is to run playwright.js browser automation scripts
@Valentim_Gab10 ай бұрын
When the session expires and the tokens refresh, if you don't press F5, it keeps calling the API thousands of times and when the Refresh expires it gives a lot of errors.
@csdsolutions47472 ай бұрын
This was a nice tutorial... what if a user change their system time won't it keep their token from expiring
@SakuraDev2 ай бұрын
I have created a new version of this video in which I addressed this issue. It will be uploaded tomorrow
@surajrlucas9 ай бұрын
Briefly skimmed through the vide and it look like exactly, what I was looking for. Just had a quick question, my backend for user authentication is developed in Django, but this will be the same right? Thanks!
@SakuraDev9 ай бұрын
Hey 👋. Thanks 👍. Yes the nextjs part is the same.
@Thekjabar13 күн бұрын
excellent video just I dont know where is login page located
@SakuraDev5 күн бұрын
Hi 👋 it is on the /auth/signin
@nitishdesigns421011 ай бұрын
I have one doubt. How to logout user when refresh token is expired?
@waltervanwoudenberg6876 Жыл бұрын
Monorepo with nextjs + nestjs using drizzle and next-auth with the drizzle adapter would be cool video to watch. Where both next and nest share this drizzle db
@SakuraDev Жыл бұрын
Ok, This is a nice suggestion. I put that in my list
@anowarulhassan5117 Жыл бұрын
Awesome👍👍👏😊😊
@SakuraDev Жыл бұрын
Thanks for the visit
@milesrykerodazie171 Жыл бұрын
Thank you so much for this video.I have done authentication with cookies using nestjs and using the api with nextjs 13.on my local host , it works very well and sets the cookie and persists on page refresh.but when i deployed the nestjs api the cookies does not set at all.the login is successful but the cookies dont set.I have tried several solutions but i still get same issue.any idea on how i can go about this? i will really appreciate help on this.Once again thank you so much
@davithchhung7577 Жыл бұрын
Nice video!
@SakuraDev Жыл бұрын
Thanks for the visit
@raff479928 күн бұрын
hello, i noticed that in your tutorial when you return from the signIn screen the user data is already loaded, how did you do that? i'm following the tutorial but when i return from the signIn page the signIn and signUp buttons appear for a brief moment until getSession() puts the data in the react state, thanks for your attention (sorry if it seems confusing, I'm from Brazil and I used the translator to write this LOL)
@SakuraDev27 күн бұрын
Hi, 👋 The auto fill is because of the browser, saved the user name and password. Second question: that is because the sign in button component is a client component. If we turn it to a server component, the problem will be fixed.
@alemendieta334610 ай бұрын
Great tutorial! How can i implement both Credentials and oAuth providers in Auth.js, but with my backend logic in NestJs? That is, store my users in DB, but only NestJs can read/write database?
@SakuraDev10 ай бұрын
Hi thanks 🙏. About your question, yes we can it is little different. Actually I am planning for creating a video about it.
@kellslte Жыл бұрын
I love this tutorial! I have been looking for something like this but then I have an issue. I started following the tuorial as I did not have any issues on the backend setting up the things I set up but then I had serious issues with the Next.js next-auth. I am hitting the endpoint but then I am not getting results. I have tried to log the response to see what it contains but then I see nothing in the console. I suspect that it does not log anything because the page refreshes everytime I enter the credentials. Also my return object from the backend is different yours in the video but I was under the impression that I should be able to customixze it to do what I want to, but back to my question, what do you think could be the reason for this?
@leobaldoneto8 ай бұрын
Check about the useSession. If you are using the NextJS 14 with server components, it will not work.
@danimusbar Жыл бұрын
tks for your kindness sharing this nestjs, this is i am looking for.. please make another video full stack using nest js and next js, like marketplace or airbnb or linked in.. tks
@SakuraDev Жыл бұрын
Thanks 🙏, I will do that
@guilhermecfialho Жыл бұрын
Hi there, Nice video... but i have a question, when you navigate into other tabs and came back, it really does the refresh token, but it does not work well while navigation into others routers and reloading page (f5, and others reloads methods) there is an method to solve this problem, to when it reloads the page it does the refreshToken, if accessToken expired? I know in other video that you made, it works but in the client side, but i want to know if there is an way to do in the server side, thanks
@ahmedf2 Жыл бұрын
in min 22:00, why you didn't provide the hash salt (which you set to 10 breviously) while comparing the given password and the stored password hash? N.B: here is the code snippet I am asking about : await compare(dto.password, user.password)
@SakuraDev Жыл бұрын
Hey, when comparing, we don't need to pass the salt rounds.
@ahmedf2 Жыл бұрын
@@SakuraDev why, isn't the salt affect how the hash output will look like?
@SakuraDev Жыл бұрын
@@ahmedf2 Really nice question. The compare function's role is simply to check if the two hashes match. The salt and the number of rounds used for hashing are known and stored with the hashed password, so there's no need to specify them in the comparison function.
@OnlyJavascript Жыл бұрын
why use nest for back-end? is this for educational purpose or next can't handle back-end services?
@SakuraDev Жыл бұрын
Next.js can handle backend services. But for scale projects, definitly, you need a powerfull backend framework like nest.js.
@OnlyJavascript Жыл бұрын
@@SakuraDev thank you sir.
@johnkucharsky6927 Жыл бұрын
@@SakuraDev what is so powerfull in nestjs? next can handle all this easily. If you don't use backend for other projects, you can use next
@SakuraDev Жыл бұрын
@@johnkucharsky6927 for example , with nest.js you can easily create microservices.
@kubilaybzk Жыл бұрын
İ have a small and important question. We have an api that lists one product. We will ensure that the products are listed by using this api in the admin panel. Let's assume that we get the token information thanks to NextAuth, so we need to use it in the api as headers: {Authentication: 'Bearer {token}'}. When the page is first loaded, NextJS does not know what this "token" information is, so it crashes while fetch. And the products unfortunately do not appear on the screen. Is there any chance we can do this without putting a talk like if(token) ?
@SakuraDev Жыл бұрын
Hi, It seems you are fetching your product in a client component. I would recommend to fetch data in a server component and the create a loading.tsx page in the same level of that page and then inside the loading just render a spinner or a loader or... The next.js will show the loading page, while your data if fetching
@mahers8172 Жыл бұрын
awesome ! but I got issu when I refresh the token for the first time it's work but then will refresh secend time it's send the same old refresh token
@youngming7752 Жыл бұрын
Good video except that you left out an important part: Checking if the refresh token is expired. In a comment below u mentioned that you should just call the sign out function in this case but inside the jwt callback it is not possible to call that function. Yes you could run it inside the protected page but that is also not practical if there are multiple protected pages. Then there is also the middleware.ts but when calling the sign out function there and redirecting the user, a window is not defined error is being thrown...
@SakuraDev Жыл бұрын
Thanks for bringing that to my attention 🙏
@youngming7752 Жыл бұрын
@@SakuraDevI found a very simple solution for this. We can include the "session" option in inside [...nextauth].ts right after the "callbacks" option. There we set strategy to jwt and maxAge to the same lifetime that we specified for the refresh token in the custom backend. The session lifetime and refresh token lifetime will be synchronized that way. If the lifetime for the refresh token is 7 days (and session maxAge 7 days) and the user visits the page after 7 days, the session (from the session option) will be expired and the user will be logged out. Hope this helps anyone having the same issue
@youngming7752 Жыл бұрын
There is also another big issue: When reloading a page manually the jwt callback is being triggered, but the jwt callback is not being triggered on page transitions. So if the user stays on the same page until the access token expires and then e.g. submits something using a button click, he will provide the invalid access token because it has not been refreshed. I also figured out a solution for that which includes using the refetchInterval option from the SessionProvider component
@hasanulhaquebanna Жыл бұрын
Appreciate your dedication! I have a question about the token stuff! In real-world projects I think, refresh token stuff works like when accessToken expires then again call for access token (till refresh token not expire), and when refresh token expire then user should logged out meaning need to login and new refresh token add. But in your case, it's not working like that, may I know why?
@SakuraDev Жыл бұрын
Exactly. My solution is following that approach. Is there a problem with that?
@hasanulhaquebanna Жыл бұрын
@@SakuraDev I think you're doing that with client side, because i didn't get any of that idea properly from backend! That's why get confused, plus you didn't send any token in cookies through backend
@SakuraDev Жыл бұрын
@@hasanulhaquebanna there are two approach for authentication in backend. Stateless which uses jwt and stateful which uses session in backend. You are talking about session based auth and I talk about stateless auth.
@hasanulhaquebanna Жыл бұрын
@@SakuraDev thank you so much for clarification but with jwt we can also get both approaches right? That is what I tried to say
@SakuraDev Жыл бұрын
@@hasanulhaquebanna yes we can use both. 🙏👍
@asadmehboob1300 Жыл бұрын
can we save user records from Next Auth google provider to nestjs and then database?
@SakuraDev Жыл бұрын
Yes we can. In next auth events and callbacks we can do that. In my next video I will do that.
@asadmehboob1300 Жыл бұрын
@@SakuraDev ty great
@JoãoBisinotti6 ай бұрын
what about the deprecation warnings for bcrypt dependecies? You didn't get that on your installation but I saw more people with this issue
@SakuraDev6 ай бұрын
I will upload an update for this video
@phongngo315 Жыл бұрын
Hello Sakura Dev, today I watched a lot of videos of you. But I still have some questions, please help me :((. I'm building a fullstack website with NextJS. I'm using NextAuth for authentication. And now I can login by credentials and some third app, but I want to have a jwt token to middleware protect when success logged in. But in my session, I don't have any jwt token. How can I achieve it or Do I have to do it? Is safe when return the id in the session? I have tried to return the public information of user in session, and they id I save in jwt, is that right?
@SakuraDev Жыл бұрын
Hey. So you want to protect some pages with next auth middleware?
@phongngo315 Жыл бұрын
@@SakuraDev Yes, I want protected my post api, because I return the user id in session, so I nervous that can be got by somebody, and they can do a post api
@sudam-d Жыл бұрын
Hi, There is a small issue with the current Nextjs setup. Say that an endpoint is going to be hit on a button click in client side. If the token has expired, the jwt callback does not get called. It gives a 401 unauthorized. Any suggestions on how to fix it? I apprecaite your content. ♥
@SakuraDev Жыл бұрын
Yes that's one of the edge cases. let me see how I can handle that. I will let you know. BTW thanks for bringin that to my attention
@muhammadusama7121 Жыл бұрын
@@SakuraDev Any update on this ? or do you have any suggestions how it should be handled. So I might look into this as well.
@SakuraDev Жыл бұрын
@@muhammadusama7121 Hi, In the next week I will come up with solution.
@dimashiskenderov498 Жыл бұрын
@@SakuraDev Awesome video, but for my project I have stumbled on the same issue. I found your older video where you manually update session, should I use that approach when hitting 401 on client side? kzbin.info/www/bejne/iIHPYaVjjtFpprc
@sudam-d Жыл бұрын
HI, I came up with a solution. Let me know whether you need me to share the code to have a look!
@andrechaves4116 Жыл бұрын
thank you so much!
@SakuraDev Жыл бұрын
You're welcome! 🌷🌷
@HuyNguyen-ix4bl Жыл бұрын
i have a question , we have the api for auth using nestjs why we must do the nextjs server api ? is this because the next-auth package want it that way ? i never use the next auth package so i need some explain about that
@pirterm Жыл бұрын
Very nice tutorial. I tried to follow up the client side with Next-Auth, cause my authentication backend is already running in ASP. I noticed one issue, and maybe you can explain what is going on. When I authenticate, I'm having correct user data, access token, refresh token and expires in values, till the first refresh call. Refresh endpoint returns correct data, and the same way I'm returning new token with modified backendTokens, but then on every jwt callback, there are still the same values. So it keep refreshing token on every request. But what funny is, when I use getServerSession in Server Action, there the token is correct (refreshed one). So I ended up refreshing token on each and every request after first one expires. Has anyone noticed anything like that before?
@amritniure4653 ай бұрын
Same problem here. Did you found the solution mate?
@wervana Жыл бұрын
How to use Google Provider with it? Client is not sending password to check the authenticity of the user.
@arieldebarros Жыл бұрын
Great tutorial! How do we generate random SSL Keys on Windows machines?
@SakuraDev Жыл бұрын
Hi, You should install open ssl on your windows machine and then run this command: openssl rand -hex 32
@nidhalchelhi26554 ай бұрын
Is this better than using passport ? and how can I fix the issue of importing the JwtService in every module i have ?
@SakuraDev4 ай бұрын
No it's not better. I just wanted to show how auth works deep inside nestjs. you can use passport. you can check my recent NestJs Full course for that.
@SakuraDev4 ай бұрын
and for your second question, I guess registering that in the app module will do the trick for you.
@nidhalchelhi26554 ай бұрын
@@SakuraDev thank you for the reply, i just got one more question to ask! when i refresh the tokens.. the old access token should not work anymore right ? but i noticed that it's still working for me
@SakuraDev4 ай бұрын
@@nidhalchelhi2655 Yeah, we need to invalidate the tokens. You can just watch this to do that: kzbin.info/www/bejne/moa3fImPoKmnrpI
@en_kratia Жыл бұрын
Thank you very much
@SakuraDev Жыл бұрын
Thanks, I hope it was helpful
@denvudd4492 Жыл бұрын
Hey, can you please make the video where you combine custom credentials and Google Provider for example? It works cool for now, but in my app, I want to add OAuth and I can't figure out how I need to combine these 2 flows. Like we need a password for user creation, right? Do we need to create a separate model for OAuth users? Thank you again friend!
@Maulanafb11 ай бұрын
Yeah
@alirezak5870 Жыл бұрын
آقا وحید من یه چالش تو پروژه شرکتمون دارم که ساخت فرم ساز هستش بک اندمون لاراول هستش ورودی های فرم همون اینپوت هاش ساختار جی سان ذخیره میشه مثلا تایپ اینپوت تکست یا نامبر خیلی هم ابتدایی ینی ایونتارو فعلا ذخیره نمیکنیم من خواستم با formbuilder پیادش کنم متاسفانه پکیجش جی کوئری هستش برا ری اکت شما چه پکیجی رو توصیه میکنید من هرچی گشتم چیزی پیدا نکردم که خوب پوشش بده مسئله ساخت فرم انگار باید از اول چرخ بسازم و ددلاینمون همش یک هفتش مونده از تایپ اسکریپتم استفاده میکنم و نکست جی اس
@alirezak5870 Жыл бұрын
مثلا اکثر پکیجایی که برای ساخت cms هستن اشتراکای سنگین دارن که برا بلند مدت کاربرد ندارن مثلا فایل منیجر sync fusion یا x data grid جداول متریال یو آی که پجینیت ای پی آی یا اینفینیت اسکرول ندارن بنظرم کانسپتای خوبی هستن برای تولید محتوا
@SakuraDev Жыл бұрын
age dorost motevajeh shode basham, shoma mikhahid be sorat dynamic ye form ro besazid ke har dafe tedad input ha motefavet hast. agar masale in hast kheili rahat ba reach-hook-form mitoonid anjab bedin.
@alirezak5870 Жыл бұрын
are masalan ye sidebar hast dakhelesh anvae objectaye form hast button checkbox input type ha bad ba dnd kit inaro drop konim to content nahayat json sakhte shode az on sidebar to db zakhire konim va samte front roosh map bznim karbar btoone poreshoon kone va submit kone @@SakuraDev
@pde21315 ай бұрын
Thanks
@SakuraDev5 ай бұрын
You’re welcome 😊
@leonrxyАй бұрын
How can users who have been authenticated no longer be able to log in to the login page? and automatically redirect to the dashboard. I can't use getServerSideProps and I don't want to use useeffect because it's very delayed please help me, thankyou
@SakuraDev27 күн бұрын
You can check it in the middle ware and put your login page into the protected pages list in the middle ware.
@rorn-dev Жыл бұрын
i have a question. like we know next auth is default to 7d but when we use refresh token like this that back end token will more than 7d right . so if the nextauth session was expire what happen here ?
@SakuraDev Жыл бұрын
so you want the backend tokens to be expired when next-auth session is expired?
@rorn-dev Жыл бұрын
@@SakuraDev no. coZ back end refresh token is keep refreshing so it is mean that the time of refresh token is keep longer and longer . back to our next auth session we just use the default to 7day so this point it will not sync . what i want is to make sure that next auth session is expire when the refresh token is expire to keep it sync i hope you get my purpose
@jaspreetmaan121 Жыл бұрын
How can I add google-provider with this method
@SakuraDev Жыл бұрын
I am going to create a video about it,
@michaeltrembovler8301 Жыл бұрын
I 'd faced the problem of CORS Error when sends POST request by await fetch(Backend URL + "/auth/register" {...}) from the client side. Will be very thankful for answer.
@tayutai1616 Жыл бұрын
I solved that problem by adding `app.enableCors()` to main.ts of Nest.js project.
@Maulanafb11 ай бұрын
hello sakura how to authenticate nextjs with nestjs backend with oauth nextauth
@okao0811 ай бұрын
How do i implement google auth using nestjs as backend and nextjs as the frontend?
@Maulanafb11 ай бұрын
do you get the solution?
@SakuraDev11 ай бұрын
I have a solution in my mind, but I am not sure it is the best solution. So, I will do some research about it and then I will make a short tutorial for that with the best solution.
@okao0811 ай бұрын
@@SakuraDev My use case is that i have an application that requires normal email based login + social logins such as google and apple. for now since i couldn't find a way to implement it using next auth i am using another approach. But I really want your help to see if there is a better way. thank you and keep and wish you a very happy new year 🙂 Cancel Reply
@Maulanafb11 ай бұрын
@@SakuraDev Thank u Sakura dev , i cant wait for the tutorials
@saifhaq499811 ай бұрын
Awesome Tutorial........... Can you make one with GRAPHQL please
@SakuraDev11 ай бұрын
Put it on my list
@matheusdesousamenezes514 Жыл бұрын
Wonderful tutorial! I would like to ask a question that i couldn't understand in the NextAuth docs: Lets say that we have two computers: "A" and "B". - I log in with with my account in computer "A" - Then i log in with the same account in computer "B" I understand that computer "B" should have the refreshed token, and computer "A" should have it's own token as invalid (therefore the refresh endpoint would give an error). But how does NextAuth deals when the HTTP call inside the refreshToken function gives an error? Does it erases the cookie? Sorry for the bombarding of questions, and again, many thanks for the tutorial! EDIT: I think the problem of my question is more about the business model of the api (if the backend allows two active tokens at the same time for example), but i still would like to know what should happen if that refreshToken gives an error hehehe
@SakuraDev Жыл бұрын
Hi, In this project, the backend does not keep track of the jwts, so it allows multiple valid jwt as far as they are valid and not expired. if you want to keep track of active jwts, you should store them in a db when you are creating them.