Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Login System


Go to End


2 Posts   988 Views

Avatar
Bagzli

Community Member, 71 Posts

6 September 2015 at 3:41am

Hello,

I am trying to build a registration and login system. I have come upon an issue that I'm not sure how to solve. One of the requirements that I have is that the users who do not have required access of an administrator and attempt to access any admin pages or such should get a 404 error. Basically page not found.

I have tried something like this in my _config.php file but that forces the 404 page every time. I need the admins to still be able to log in.

Keep in mind this doesn't check for admins, just checks if you are logged in (meant to be just for testing)

if(!Member::currentUserID() ) {
    Director::addRules(30, array(
		'admin' => '->page-not-found',
		'interactive' => '->page-not-found',
		'DevelopmentAdmin' => '->page-not-found',
		'DatabaseAdmin' => '->page-not-found',
		'db' => '->page-not-found',
	));
}

Avatar
swaiba

Forum Moderator, 1899 Posts

9 September 2015 at 6:52pm

try...

if(!Member::currentUserID())
	return $this->httpError(404);