Skip to content

Commit 4257202

Browse files
committed
improve methods tables
1 parent 18fd720 commit 4257202

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

docs/AuthProviderWriting.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ const authProvider = {
8989
| **Purpose** | Send username and password to the auth server and get back credentials |
9090
| **Required** | Yes |
9191
| **When to use** | For login / password flows |
92-
| **Resolve if** | Login credentials were accepted |
92+
| **On resolve** | Redirects to previous page or admin index (customizable) |
93+
| **On reject** | Displays error message in a notification |
9394
| **Request format** | `Object` with values from the login form |
9495
| **Response format** | `void | { redirectTo?: string | boolean }` |
9596
| **Error format** | `string | { message?: string }` |
@@ -153,7 +154,8 @@ const authProvider = {
153154
| **Purpose** | Check if a dataProvider error is an authentication error |
154155
| **Required** | Yes |
155156
| **When to use** | Always |
156-
| **Resolve if** | Error is not an auth error |
157+
| **On resolve** | - |
158+
| **On reject** | Logs the user out and redirects to the login page (customizable) |
157159
| **Request format** | `{ message: string, status: number, body: Object }` (error from the dataProvider) |
158160
| **Response format** | `void` |
159161
| **Error format** | `{ message?: string | boolean, redirectTo?: string | boolean, logoutUser?: boolean }` |
@@ -237,7 +239,8 @@ const authProvider = {
237239
| **Purpose** | Check if the user is authenticated (when navigating to an authenticated route) |
238240
| **Required** | Yes |
239241
| **When to use** | Always |
240-
| **Resolve if** | User is authenticated |
242+
| **On resolve** | - |
243+
| **On reject** | Logs the user out and redirects to the login page (customizable) |
241244
| **Request format** | Params passed to `useCheckAuth()` -- empty for react-admin default routes |
242245
| **Response format** | `void` |
243246
| **Error format** | `{ message?: string | boolean, redirectTo?: string | boolean }` |
@@ -311,7 +314,8 @@ const authProvider = {
311314
| **Purpose** | Log out the user from the backend and clean up authentication data |
312315
| **Required** | Yes |
313316
| **When to use** | Always |
314-
| **Resolve if** | Auth backend acknowledged logout |
317+
| **On resolve** | Redirects to login page (customizable) |
318+
| **On reject** | - |
315319
| **Request format** | - |
316320
| **Response format** | `string | false | void` route to redirect to after logout, defaults to `/login` |
317321
| **Error format** | - |
@@ -355,7 +359,6 @@ const authProvider = {
355359
| **Purpose** | Get the current user identity |
356360
| **Required** | No |
357361
| **When to use** | Always |
358-
| **Resolve if** | Auth backend returned identity |
359362
| **Request format** | - |
360363
| **Response format** | `{ id: string | number, fullName?: string, avatar?: string }` |
361364
| **Error format** | `Error` |
@@ -405,10 +408,11 @@ const PostDetail = ({ id }) => {
405408
| **Purpose** | Process authentication callback from third-party providers (Auth0, Cognito, ...) |
406409
| **Required** | No |
407410
| **When to use** | For third-party authentication flows |
408-
| **Resolve if** | User is authenticated |
411+
| **On resolve** | Redirects to previous page or admin index (customizable) |
412+
| **On reject** | Renders the error |
409413
| **Request format** | - |
410414
| **Response format** | `void | { redirectTo?: string | boolean }` |
411-
| **Error format** | `{ redirectTo?: string | boolean, logoutOnFailure?: boolean, message?: string | boolean }` |
415+
| **Error format** | `Error` |
412416

413417
This method is used when integrating a third-party authentication provider such as [Auth0](https://auth0.com/). React-admin provides a route at the `/auth-callback` path, to be used as the callback URL in the authentication service. After logging in using the authentication service, users will be redirected to this route. The `/auth-callback` route calls the `authProvider.handleCallback` method on mount.
414418

@@ -480,7 +484,6 @@ const authProvider = {
480484
| **Purpose** | Check authorization for an action over a resource |
481485
| **Required** | No |
482486
| **When to use** | For [Access Control](./Permissions.md#access-control) style Authorization |
483-
| **Resolve if** | Auth backend returned authorization |
484487
| **Request format** | `{ action: string, resource: string, record: object }` |
485488
| **Response format** | `boolean` |
486489
| **Error format** | `Error` |
@@ -532,7 +535,6 @@ Check the [Access Control documentation](./Permissions.md#access-control) for mo
532535
| **Purpose** | Returns a boolean indicating whether the user can perform the provided action on the provided resource |
533536
| **Required** | No |
534537
| **When to use** | For [Permissions](./Permissions.md#permissions) style Authorization |
535-
| **Resolve if** | Auth backend returned permissions |
536538
| **Request format** | params passed to `usePermissions()` -- empty for react-admin default routes |
537539
| **Response format** | `any` |
538540
| **Error format** | `Error` |

0 commit comments

Comments
 (0)