Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redirect logged users to /home #640

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Aug 17, 2024

Summary

Closes: https://github.com/snapshot-labs/workflow/issues/158

This PR will redirect logged in users to /home when requesting for /

How to test

  1. Go to /
  2. It should show a loading indicator until it detect whether you're a guest or connected user
  3. If you're not connected, it should show the landing page
  4. If you're connected, it should redirect to /home

Note

This will always show the Loading icon until the log in is complete.

When you're logged in, but with metamask locked, it will show the loading indicator until you unlock metamask, or reject the unlock.

@wa0x6e wa0x6e requested a review from bonustrack August 17, 2024 10:18
</script>

<template>
<div>
<div v-if="!authInitiated || web3.authLoading" class="p-4">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If metamask is locked

Untitled 4

Is it expected? feels bit weird

Copy link
Member

@ChaituVR ChaituVR Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we want to show a loader here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not flash the landing page.

Else, it will show the landing page, while we're connecting the user async

Copy link
Member

@ChaituVR ChaituVR Aug 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have some localstorage variable (add value when user connects and delete if the user logout)
if user have this value, we should always redirect to /home , else show /

Then we wait for user wallet connection on /home, if user fails to connect his wallet, we should delete localstorage variable and redirect back to /

(also we should not try to auto-connect if user doesn't have this localstorage value, this may solve #478)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that we can not differentiate if the user is ready to be logged or if Metamask / user wallet is locked, this cause an issue where Metamask or WalletConnect will be triggered for login on first page load. Wagmi may fix that, or it could be with a change on Lock.

Copy link
Member

@bonustrack bonustrack Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ideal behavior would be similar than Uniswap (which is using Wagmi), where user dont get Metamask or their wallet triggered if it's locked, but still autoconnect if it's not locked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ideal behavior depends on some changes on lock side, and will be on another PR

@wa0x6e wa0x6e requested a review from Sekhmet August 26, 2024 13:12
Copy link
Member

@Sekhmet Sekhmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@bonustrack
Copy link
Member

Let's merge this when we can actually, it make much easier to test

@bonustrack bonustrack merged commit 54c2cbe into master Aug 27, 2024
3 checks passed
@bonustrack bonustrack deleted the feat-redirect-logged-user-to-home branch August 27, 2024 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants