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

bug: user has to re-login every time chrome sidepanel opens #5297

Open
AdityaPimpalkar opened this issue May 6, 2024 · 2 comments
Open

bug: user has to re-login every time chrome sidepanel opens #5297

AdityaPimpalkar opened this issue May 6, 2024 · 2 comments
Labels
type: bug Something isn't working

Comments

@AdityaPimpalkar
Copy link
Contributor

Bug Description

Chrome sidepanel doesn't persist state in the background, every time we close/open sidepanel it loses its previous state and restarts again. So we end up having to login everytime.

Screen.Recording.2024-05-06.at.8.29.23.AM.mov

Expected behavior

Ideally need to bypass login automatically and directly route to desired page

Technical inputs

One way could be to use our /verify route with authToken as query parameter, like /verify?authToken=.... similar to loginToken query parameter which is already present. We can get our authToken from chrome's storage, verify it on backend and return if its valid, then set the required state for the app to load and then redirect it to our desired route

@AdityaPimpalkar AdityaPimpalkar added the type: bug Something isn't working label May 6, 2024
Copy link

greptile-apps bot commented May 6, 2024

To resolve the issue of the user having to re-login every time the Chrome sidepanel opens, you can implement a solution that checks for an existing authentication token in Chrome's storage and uses it to verify the user's session automatically. Here are the specific steps to implement this solution:

  1. Modify the Background Script (/packages/twenty-chrome-extension/src/background/index.ts):

    • Add a function to check for an existing authToken in Chrome's storage upon opening the sidepanel.
    • If an authToken exists, use it to make a request to the /verify endpoint to validate the token.
    • Based on the verification response, automatically set the user's authentication state in the extension.
  2. Update the Content Script (/packages/twenty-chrome-extension/src/contentScript/index.ts):

    • Adjust the authenticated function to check for an authToken instead of a loginToken.
    • If the token is valid, directly load the user's desired page without requiring a login.
  3. Adjust the Options Page Script (/packages/twenty-chrome-extension/src/options/Options.tsx):

    • Ensure that the authentication flow considers the presence of an authToken to bypass the login screen if the token is valid.

By implementing these changes, the extension will be able to maintain the user's authentication state across sidepanel sessions, eliminating the need for repeated logins.

References

twentyhq/twenty/packages/twenty-chrome-extension/src/background/index.ts
twentyhq/twenty/packages/twenty-chrome-extension/src/contentScript/index.ts
twentyhq/twenty/packages/twenty-chrome-extension/src/options/Options.tsx
twentyhq/twenty/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
twentyhq/twenty/packages/twenty-front/src/modules/auth/components/VerifyEffect.tsx

Ask Greptile

@GTgyani206
Copy link

If the issue is still open, I would like to work on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@AdityaPimpalkar @GTgyani206 and others