Users still able to access default EE CP home
mrtopher opened this issue · comments
The one thing I have been unable to figure out is how to keep users from being able to bring up the default EE CP. Using hooks I can redirect the user upon login and using javascript I can change the home and breadcrumb links. But there are intermittent instances when users will still be redirected to the default EE CP.
Would love to find a way to redirect any requests to ?D=cp&C=homepage to dashEE but I'm not sure how yet.
Hi Chris,
Have you considered using "sessions_start" hook for the purpose of redirecting from ?D=cp&C=homepage to D=cp&C=addons_modules&M=show_module_cp&module=dashee ?
Thanks for the suggestion Laisvunas. If I were to use this I would be checking the URL for "?D=cp&C=homepage" and redirecting manually if it's a match?
Chris,
You would just do something like this:
if (REQ == 'CP' && $this->EE->input->get('C') == 'homepage')
{
// redirect here...
}
Thanks Erik, I'll give this a try.
This might be silly question, but I tried using session_start as recommended but I'm getting hung up because I loose access to constants like BASE. I assume this is because session_start is fired before such constants are set. This is a problem because without that value I'm unsure of how to get the address for redirecting the user.
Am I missing something obvious here?
Hi Chris,
If BASE constant isn't set when "sessions_start" functions are executed, then BASE constant can be easily defined inside function itself. That is, inside function can be easily done the same as in the file /system/expressionengine/libraries/Core.php:
$s = 0;
if ($this->EE->config->item('admin_session_type') != 'c')
{
$s = $this->EE->session->userdata('session_id', 0);
}
define('BASE', SELF.'?S='.$s.'&D=cp'); // cp url
sessions_end has the userdata ready and set.
that way you can also verify if the user has access to DashEE.
#17
Post Scriptum: Special thanks to @erikreagan and @Laisvunas for pointing in the right direction for this fix.