Hi everyone,
Based on the Phalcon MVC Examples, i started to develop a multiple modules application with the attached folders structure.
Each module is attached to a router group (front, back, api) with their own subdomain (www.myapp.com, app.myapp.com and api.myapp.com).
Controllers in the back module directory extends the BackController in the regular Controllers directory. Controllers in the front module directory extends the FrontController in the regular Controllers directory.
To be sure that the user can access to the backend (which is a private resource), i have the following check done
class BackController extends ControllerBase
{
public function beforeExecuteRoute(Dispatcher $dispatcher): bool {
// User is logged ?
$identity = $this->auth->getIdentity();
if (empty($identity) && !is_array($identity)) {
// Redirect user to login
$this->flash->error('error_user_not_logged');
return false;
}
return true;
}
...
}
I want to be able to redirect the user from the subdomain app.myapp.com to www.myapp.com/signin when the user i not logged. It seems to be a basic need, but for some reason i'm not able to find the correct way to do it. I thought using the Manager as a provider listening to the event 'dispatch:beforeForward' would help, but nor fowarding or redirect using route name change the subdomain.
Anyone can help ? Thanks, take care