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

Custom routes without auth doesn't work after add permissions to resources #4821

Closed
ackalhan opened this issue May 17, 2020 · 6 comments
Closed

Comments

@ackalhan
Copy link

ackalhan commented May 17, 2020

What you were expecting:
I have few custom routes for forget password and reset password after i update permissions for the resources iam expecting those two pages are working as before

What happened instead:
once i click on forget pwd link it will redirect to the login page

Steps to reproduce:

Related code:
image

@fzaninotto
Copy link
Member

I believe that's because your route contains the string '/login'. Try using a route path without that string.

@ackalhan
Copy link
Author

I have tried by putting
image

but still the same issue happens
anyway i have figured it out, that because on each route change getPermissions and checkAuth is calling in authProvider, since i don't have the token and the permission at that time it will reject the promise and that will redirect it back to the login

So i have check the window.location.hash is related to non-auth route then i have resolved the promise

image

It's better if there's a way to define non auth routes like login page

@fzaninotto
Copy link
Member

React-admin should not call checkAuth on custom routes. You're likely doing it yourself in your ForgotPassword and ResetPassword components.

Anyway, since the problem is solved on your side, I'm closing this issue.

@ackalhan
Copy link
Author

@fzaninotto i guess no because it was working well until i add the permission to resources

@alextaymx
Copy link

Hi there, I am having the same issue, custom pages are protected by auth provider, i couldn't proceed to other pages without log in, also after configuring getPermission method in authProvider

@dioris-moreno
Copy link

dioris-moreno commented Oct 15, 2024

If somebody has this problem in 2024, the issue could be how you link your custom pages. As stated in the documentation, you have to link your custom pages using react-router’s Link component.

From Linking To Custom Routes

import { Link as RouterLink } from 'react-router-dom';
import { Link } from '@mui/material';

const SettingsButton = () => (
    <Link component={RouterLink} to="/settings">
        Settings
    </Link>
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants