trypear / pear-landing-page

Landing page for PearAI, the Open Source AI Code Editor
https://trypear.ai
Apache License 2.0
65 stars 87 forks source link

callback with access_token and refresh_token when visited from pearai-submodule #118

Open nang-dev opened 4 months ago

nang-dev commented 4 months ago

Step 1 (Done)

We want to be able to sign-in via the pearai-app.

To do this, when the user clicks "Login" in the app, the app will open up localhost:3000/signin?callback=code-oss://pearai.pearai/auth (for local)

CURRENT STATE:

callback is not processed.

WHAT WE NEED:

if there exists the callback param, after signin, the webapp should redirect to this link

code-oss://pearai.pearai/auth?accessToken=&refreshToken=

these values can be fetched like this: https://github.com/trypear/pear-landing-page/pull/94/files#diff-714741c416aa1a405e005664d443313c48048062f768b48485a802e5d2d8fcceR40

Step 2

If user already logged in, when going to this link localhost:3000/signin?callback=code-oss://pearai.pearai/auth, should go to settings page and ask to open desktop app.

Currently, if you're already logged in on the web, and you enter that url again, it just brings to the home page ((auth)/signin.tsx).

Expected behaviour is should bring to settings page, and pass in the callback, access token and refresh token. See the signin function currently in (auth)/actions.ts which already does it for if user signs in directly from pearai app. Essentially needs to do the same.

(Enter localhost:3000/signin?callback=code-oss://pearai.pearai/auth directly in your browser while running app locally to test this)

dscreet commented 4 months ago

going to have a go