BuidlGuidl / grants.buidlguidl.com

https://grants-bg.vercel.app
MIT License
3 stars 3 forks source link

Admin route (soft) view access #96

Closed carletex closed 6 months ago

carletex commented 6 months ago

Let's soft-protect the /admin route. Data is not secret anyway, but let's now allow /admin direct access.

As we discussed on https://github.com/BuidlGuidl/grants.buidlguidl.com/pull/18 and https://github.com/BuidlGuidl/grants.buidlguidl.com/pull/17, if we wanted full protection, we could do SIWE + JWT or signed reads. We might want to consider it in the future.

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
grants-bg ✅ Ready (Inspect) Visit Preview Mar 26, 2024 10:10am
carletex commented 6 months ago
  useEffect(() => {
    if (!address) router.push("/");
  }, [address, router]);

Hey @technophile-04 , the problem with this is that address might be undefined while the hook is "connecting". It won't happen if you are already on the page and navigate to /admin, but it happens if you go directly to /admin... so you get redirected haha

image

I'll be interested to know how to fix this for other occasions (isConnecting doesn't seem to work)


Merging this for now... since I think we'll be changing it soon haha (Austin is more inclined to do a SIWE + validation). I'll open an issue.

technophile-04 commented 6 months ago

but it happens if you go directly to /admin... so you get redirected haha

Ohhhhh yes!! my bad, missed it completely sorry :(

(isConnecting doesn't seem to work)

Yeah :(, I think since we are using our custom solution useAutoConnect hook for auto connecting I think because of this wagmi isn't aware about its status.

Umm not sure what's the best solution is maybe very hacky solution : exposing some kindof isLoading/isConnecting state from useAutoConnect hook

But yup this should be solved in Wagm v2 though 🙌