marmelab / ra-supabase

Supabase adapter for react-admin, the frontend framework for building admin applications on top of REST/GraphQL services.
MIT License
142 stars 26 forks source link

Signup flow not working as intended #16

Closed jlwbr closed 1 year ago

jlwbr commented 2 years ago

After following the example provided by the docs, after clicking the link in my email, i'm not able to set my password.

I have also tried setting the Site URL setting in supabase to http://localhost:3000/set-password, but that didn't work either. Going to the endpoint manually results in an instant redirect to the dashboard.

djhi commented 2 years ago

I forgot to add a requirement: you have to set the <Admin> history prop to use a BrowserHistory.

import { createBrowserHistory } from 'history';

const history = createBrowserHistory();

const App = () => (
    <Admin history={history} /* other props */>
        {/* ... */}
    </Admin>
);

This is required because supabase passes the auth token and type parameters through the url hash. That conflicts with the hash router.

djhi commented 2 years ago

Actually it seems to work fine on the demo with the browser history. Can you confirm it works after making the changes I suggested?

oskarissimus commented 2 years ago

I have similar problem. I have just started supabase with docker-compose, than npx create-react-app test, than I pasted code from README. After that i had to prepare invite link (the same with password reset) from email. i got /auth/v1/verify?token=QUbeyHbhrqUM5N0PH9WDRg&type=invite&redirect_to=http://localhost:3000/ in email, than i changed it to http://localhost:8000/auth/v1/verify?token=QUbeyHbhrqUM5N0PH9WDRg&type=invite&redirect_to=http://localhost:3001/set-password this is because kong is on localhost:8000 and react app is on localhost:3001 than it looks like I am authenticated (i can go past login screen) but i cant get to /set-password route. Maybe I am doing smthing wrong?

benjamindell commented 2 years ago

I have the exact same problem. It's infuriating - for whatever reason, I can't seem to get to the set-password screen. It just sends me to the dashboard as though I am authenticated, even though I am not (yet when I am on the dashboard I obviously cant retrieve any data because I am not authenticated).

I am using next.js and have added history={history} to the Admin component, as per the above instruction.

Did anyone manage to solve this?

zovitch commented 1 year ago

Hello, I have a similar issue with login, after following the readme instructions I get a hook error from the Login component. Is there anyways to fix this?

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Mikilll94 commented 1 year ago

@djhi This bug is still present. Any update on this?

djhi commented 1 year ago

This should be fixed in 2.0.1

spyriaev commented 1 year ago

@djhi I updated ra-supabase to the latest version 2.0.1. Regarding to the README.md I configured Site URL and Redirect URL as http://localhost:3000/ and http://localhost:3000/handle-callbackand respectively and email templates to "{{ .ConfirmationURL }}/handle-callback"

I am getting an 404 error when I press "Reset Password" and go to the link in a email "http://localhost:3000/handle-callback#access_token=[token]&expires_in=3600&refresh_token=[token]&token_type=bearer&type=invite"

I use dependencies:

 "dependencies": {
    "@promitheus/ra-data-postgrest": "^1.2.2",
    "@raphiniert/ra-data-postgrest": "^1.2.0",
    "@supabase/auth-helpers-nextjs": "^0.5.6",
    "@supabase/auth-helpers-react": "^0.3.1",
    "@supabase/auth-ui-react": "^0.3.5",
    "@supabase/supabase-js": "^2.10.0",
    "@types/node": "18.14.6",
    "@types/react": "18.0.28",
    "@types/react-dom": "18.0.11",
    "next": "13.2.3",
    "ra-data-json-server": "^4.8.2",
    "ra-supabase": "^2.0.1",
    "ra-supabase-core": "^2.0.1",
  }

And my App.tsx

const App = () => {
  return (
    <BrowserRouter>
      <Admin 
        dataProvider={dataProvider}
        i18nProvider={i18nProvider}
        authProvider={authProvider}
        loginPage={<LoginPage providers={['github', 'google']} />}
        >
        <CustomRoutes noLayout>
            <Route
                path={SetPasswordPage.path}
                element={<SetPasswordPage />}
            />
            <Route
                path={ForgotPasswordPage.path}
                element={<ForgotPasswordPage />}
            />
        </CustomRoutes>
      </Admin>
    </BrowserRouter>
  );
}

export default App;
slax57 commented 1 year ago

Hi @spyriaev , and thank you for this report. Can you check if you reproduce this issue with the demo project included in this repository? If you do, can you please open a new issue so that we can have a look? Thanks