Twill: When using ADMIN_APP_PATH, under certain circumstances admin login redirects to homepage

Created on 6 Mar 2019  路  3Comments  路  Source: area17/twill

Hi,

I changed my project's admin URL from using a subdomain to using a path. There's a small issue when logging in, where the user gets redirected to the homepage instead of seeing the Twill dashboard page under specific circumstances (see below). The problem does not occur when using a subdomain-based admin URL.

This is somewhat confusing to explain- I'll do my best!

Let's say my env variables are as follows:
ADMIN_APP_URL=myproject.com
ADMIN_APP_PATH=my-admin-panel

Let's say I'm logged out. I visit http://myproject.com/my-admin-panel, it redirects to http://myproject.com/my-admin-panel/login, I see the login form and am able to login correctly (goes to Twill admin page).

However, if I go straight to http://myproject.com/my-admin-panel/login, without the redirection from http://myproject.com/my-admin-panel, and login (eg if I was to logout and then immediately log back in again), I get redirected to my project's homepage at http://myproject.com. However if I then visit http://myproject.com/my-admin-panel I get the Twill admin page, so I am obviously being logged in even though I've not ended up at the right place.

This is a bit confusing for my project's users, so I'd appreciate it if you could have a look at this. As mentioned above, there is no problem when using subdomain-based admin URLs via ADMIN_APP_URL only.

Thanks!
Seb

enhancement question

Most helpful comment

Hi Seb!

Using the following option in your twill.php configuration file would solve this issue:

 'auth_login_redirect_path' => '/admin',

We could automate this by reading from the ADMIN_APP_PATH when provided, but in the meantime the above should work for you.

All 3 comments

Hi Seb!

Using the following option in your twill.php configuration file would solve this issue:

 'auth_login_redirect_path' => '/admin',

We could automate this by reading from the ADMIN_APP_PATH when provided, but in the meantime the above should work for you.

Yes, works perfectly now- thanks again!

@ifox , please add this to your documentation, I think many people will likely want to test twill on custom ports/sub directories and this is one of the issue that comes up when you do.

This is one of several issues that occur because hard coding of paths assumes you are running twill in the root which may not always be the case. Ie see https://github.com/area17/twill/issues/338

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vacoup95 picture vacoup95  路  3Comments

newvladimirov picture newvladimirov  路  5Comments

zipavlin picture zipavlin  路  3Comments

sebastianlenton picture sebastianlenton  路  4Comments

lostdesign picture lostdesign  路  5Comments