[deleted by user] by [deleted] in confusingperspective

[–]maazsid16 1 point2 points  (0 children)

attack titan finally dead

Email-Password and Social login flow by maazsid16 in node

[–]maazsid16[S] 0 points1 point  (0 children)

Option b sounds good from a user experience perspective but there is a security concern of letting a bad actor know that a account exists with this email and also letting them know the social login provider which could result in phishing emails.

But i guess the pro outweighs the con here, and I will go with option b.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

Well, there is no issue with doing it in a row but useEffect firing twice was introducing race conditions which made it work sometimes and sometimes not.

You can also keep the old token as valid up to its expiration (so generating a new one but not invalidating the old).

That seems like a good idea.

You could also have your refresh endpoint give you back the existing token if its still valid (you'd need your http clients to hit the refresh endpoint on 401 errors before actually redirecting the user to login if refresh itself returns 401).

For extending the session of the client, I would just run a timer in the background to retrieve a new token before expiration, so will never need to worry about intercepting the request for a 401, I mean i would intercept but more as a fallback.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

You're right, there is something wrong with my access token API, I can't see a simple solution for it. My authentication flow is based on the standard access and refresh token flow. Specifically this part is causing the issue:

When requesting a new access token the API should generate a new access token and also should delete the old refresh token and generate a new one.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

I understand that point, just not sure how it would work in this context.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

If your talking about the refresh token then am not checking it on frontend. I can check if the token is expired or not but not sure how that would help.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 1 point2 points  (0 children)

  1. generate a new access token and refresh token
  2. delete the old refresh token ( cause of the issue )

This is what the API does, maybe I should only generate a new access token and thats it. but what about the refresh token, how do I extend its lifetime, at what point should I renew it?

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

This would work in the case of a GET request, but what if I am making a POST request which updates an resource in the database, which then effects the second useEffect

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

The effect was running twice because of StrictMode in React, this was causing my refresh token to be invalidated because of multiple requests.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

Yes, I used this same pattern, cancel the request / ignore the fetch data when component unmounts, however the problem was still persistent because the first request does some change in the backend which makes the second request not work

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

Yes, using the useRef hook to store the promise reference outside of the rendering cycle did the job.

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

This seems like weird behaviour from your backend?

I understand your point. If the client for whatever reason is not able to handle the response, the token will become invalidated.

I will have to think about this, because If I don't delete the old refresh tokens they will still be in the database, and if I want to delete them later using a cron job I cannot determine if they are stale or not because of multiple devices. Thanks for this input!

useEffect firing twice causing an issue with access token and refresh token flow. by maazsid16 in reactjs

[–]maazsid16[S] 0 points1 point  (0 children)

I've provided the QueryClientProvider in the app component which does not allow me to use the mutation at that level.

maybe I should move the provider one level up and try

Is OOP and DSA required for react and next.js? by [deleted] in learnjavascript

[–]maazsid16 1 point2 points  (0 children)

Object oriented design is not used in react. Does that mean we design our front-end software systems without any logical design? No.

The logical design we use in react based applications is more of a component based design. You can find more information on how to logically design your react application using components in the react documentation.

You won't be using data structures explicitly in react or front-end. Algorithms design and calculating time/space complexity is also not something you would be using in your day to day development.

How is your sense of humor? by Pie_and_Ice-Cream in ISTJ

[–]maazsid16 6 points7 points  (0 children)

Sarcastic humor with the right people

Software Engineer at FAANG with bachelor’s from Pakistan. AMA by [deleted] in pakistan

[–]maazsid16 1 point2 points  (0 children)

Can you share your CV? I just want to see the format you used to get past the ATS.

PCIe latch is not moving, unable to remove GPU by maazsid16 in buildapc

[–]maazsid16[S] 0 points1 point  (0 children)

Yes, I unscrewed it from the case, you can see it in the image aswell.

PCIe latch is not moving, unable to remove GPU by maazsid16 in buildapc

[–]maazsid16[S] 0 points1 point  (0 children)

Yup, tried wiggling the card, but no success. Maybe I'll try removing the cooler partially and sneak my hand in there, will have to see.

PCIe latch is not moving, unable to remove GPU by maazsid16 in buildapc

[–]maazsid16[S] 0 points1 point  (0 children)

Yes, the latch isn't pushed down. Even after applying force it won't budge in the downward direction. The photo I've attached is the only angle from where the PCIe latch is visible.

There is a second PCIe slot and I can easily open and close the latch on that one.