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

Myth's routes cannot be overridden by App's ones #89

Closed
fefo-p opened this issue Aug 31, 2019 · 6 comments
Closed

Myth's routes cannot be overridden by App's ones #89

fefo-p opened this issue Aug 31, 2019 · 6 comments

Comments

@fefo-p
Copy link
Contributor

fefo-p commented Aug 31, 2019

Only by commenting out routes in \Myth\Auth\Config\Routes can App\Config\Routes be taken into consideration

@fefo-p
Copy link
Contributor Author

fefo-p commented Aug 31, 2019

Workaround, requiring myth's route file (in app's route file) so it can be overridden.
Adding the following to \App\Config\Routes does the trick

// Load the Myth's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(APPPATH . '../vendor/myth/auth/src/Config/Routes.php'))
{
	require APPPATH . '../vendor/myth/auth/src/Config/Routes.php';
}

Still, would be nice to have a better way to do it

@lonnieezell
Copy link
Owner

What version of CI are you running on? There was a bug a couple of releases back that fixed the order of routes, I believe.

@fefo-p
Copy link
Contributor Author

fefo-p commented Sep 5, 2019

At the time of this PR, devel branch. (I belive something like a week old now).
Yesterday I downloaded CI4 rc1, so I can give it a try with that.
I'll let you know later today

@fefo-p
Copy link
Contributor Author

fefo-p commented Sep 5, 2019

Just tried it. A user who only belongs to users group can still access the register url (can create users).
This is tried after commenting-out in \App\Config\Routes the line that loaded Myth-Auth's one (where it is allowed to everyone for self-registration) before actually setting the App's routes (where it's only allowed to admin groups).

Installed myth/auth from composer

"myth/auth": "1.0-beta"

PHP

PHP 7.3.8 (cli) (built: Aug  6 2019 23:15:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies

Apache

Server version: Apache/2.4.41 (Unix)
Server built:   Aug 15 2019 06:42:08

OS

macOS 10.15 Beta (19A546d)

@lonnieezell
Copy link
Owner

In a relatively clean project that I've just started, I have myth:auth installed like default.

In my app/Config/Routes.php file I add the following:

$routes->get('register', function() {
    dd('local route');
});

When I visit /register I hit the route in app/Config/Routes.php as expected. Meaning that the app can override Myth:Auth's routes. That leads me to believe your core issue isn't routes not being able to override, but something else in your app.

@fefo-p
Copy link
Contributor Author

fefo-p commented Sep 6, 2019

I tried with a brand new download of both CI4 RC1 and Auth Beta 1 and everything works fine.
Therefore, you're right when you say that I have something else going on in my app. Will have to keep digging in.
Thx

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

2 participants