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

Match new provider auth signatures v3 #148

Open
josx opened this issue Jul 10, 2020 · 5 comments
Open

Match new provider auth signatures v3 #148

josx opened this issue Jul 10, 2020 · 5 comments

Comments

@josx
Copy link
Owner

josx commented Jul 10, 2020

According to the v3 blog react admin changed its auth provider signature.

@FacundoMainere Has done a WIP on this

To be done:
We still need to be retrocompatible with react-admin v2 (last release just one year ago) and still need to make tests match current signatures.

@soullivaneuh
Copy link

I just implemented your library with react-admin v3:

import React from 'react';
import ReactDOM from 'react-dom';
import { Admin, Resource } from 'react-admin';
import { restClient, authClient } from 'ra-data-feathers';
import client from './feathers';
import './index.css';
import reportWebVitals from './reportWebVitals';

import { PostalCodeList } from './resources/postal-codes';

const restClientOptions = {
  id: '_id', // In this example, the database uses '_id' rather than 'id'
  usePatch: true // Use PATCH instead of PUT for updates
};

const authClientOptions = {
  usernameField: 'email',
  passwordField: 'password',
  // permissionsField: 'userroles',
  // redirectTo: '/signin',
}

ReactDOM.render(
  <Admin
    dataProvider={restClient(client, restClientOptions)}
    authProvider={authClient(client, authClientOptions)}
  >
    <Resource
      name="postal-codes"
      list={PostalCodeList}
    />
  </Admin>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

The login process works (the authenticate method is successful) but I am immediately logged out just after that.

Is that related to this issue?

@soullivaneuh
Copy link

soullivaneuh commented Dec 14, 2020

This basic and not complete custom implementation works:

const authProvider: AuthProvider = {
  login: (params) => client.authenticate({
    strategy: 'local',
    email: params.username,
    password: params.password,
  }),
  logout: () => client.logout().then(() => Promise.resolve()),
  checkAuth: () => client
    .reAuthenticate()
    .then(() => Promise.resolve())
    .catch(() => Promise.reject({ redirectTo: '/login' })),
  checkError: () => Promise.resolve(),
  getPermissions: () => Promise.resolve(),
}

@josx
Copy link
Owner Author

josx commented Dec 14, 2020

I dont understand if there is any error using react.-admin v3.
I suppose it is working well, but would be great if you can make effort on assure it and/or add more testing.

@sagannotcarl
Copy link

I'm having trouble getting this to work. Does anyone have a more complete working example? I tried swapping out the authClient from here #146 but I keep getting the same error: `client.logout is not a function."

@josx
Copy link
Owner Author

josx commented Jul 26, 2021

I dont understand what are you needing. Can you explain a little more?

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

No branches or pull requests

3 participants