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

Default admin doesn't have permissions


Go to End


9 Posts   2483 Views

Avatar
dylangrech92

Community Member, 17 Posts

13 April 2014 at 6:43am

Hi, after 3 days of digging around and trying to find a solution I'm stuck and require assistance.

When I try to login into the admin area of 1 of my SS3.1 sites it returns the login form as a successful login but with the only option to login as someone else.

What did I do till now?
- Was using a custom template for the admin login, removed that as well to let it ran natively
- Changed the template to use the simple template
- Cleared the cache
- Changed environment to dev ( no errors come up )
- Started fresh with a new database
- Ran Dev/Build with and without ?flush=1 & ?flush=all from command line and from browser
- Rebooted vm several times
- Tried on different browsers ( Same result except IE 10 just returns the login form )
- Placed var dumps following the request process of the login request and found myself into: LeftAndMain.php init function line 241 which looks like this: return Security::permissionFailure($this, $messageSet);

Now, what do I do to fix this? I have a live site with this problem.

Please help me

Avatar
Willr

Forum Moderator, 5523 Posts

13 April 2014 at 10:00am

Try hardcode an admin account by adding this to your _config.php

Security::setDefaultAdmin('admin', 'password');

Avatar
dylangrech92

Community Member, 17 Posts

13 April 2014 at 7:14pm

Didn't work :/

_config.php
Security::setDefaultAdmin( 'test', '123' );

and also tried:

_ss_enviroment.php
define('SS_DEFAULT_ADMIN_USERNAME', 'test');
define('SS_DEFAULT_ADMIN_PASSWORD', '123');

both return same problem.

Avatar
thomas.paulson

Community Member, 107 Posts

13 April 2014 at 9:13pm

Hello

I think you are using memberprofile module page to login, logout and to try url/admin.

Avatar
martimiz

Forum Moderator, 1391 Posts

13 April 2014 at 9:32pm

Edited: 13/04/2014 9:34pm

If
- everything used to work fine before
- you are in fact using the /admin url
- you replaced the database with a new one
- you switched back to default templates
- you manually cleared the entire cache directory

Then the one thing remaining I can think of is someting in your code that makes even the admin have insufficient rights on something the CMS loads on startup. Probably something in the SiteTree, a canview setting on a custom pagetype/module maybe. Can you pinpoint the last changes made before this started to happen? Maybe creating a page of some pagetype you hadn't used before?

Avatar
dylangrech92

Community Member, 17 Posts

13 April 2014 at 11:02pm

I'm using svn to store my code so that will be a little more helpful to trackback however didn't find anything obvious, will try again. Will come back with a reply soon :)

Thanks for the help guys

Avatar
dylangrech92

Community Member, 17 Posts

13 April 2014 at 11:27pm

The cause of all problems:

     Director::setBaseURL( 'http://'.$_SERVER['HTTP_HOST'].'/' );

The obvious questions now will be why did you do this and why was it causing so much trouble?

1) I did it because this site is hosted on a shared host in a subfolder but it's the main site so in my htaccess I have:

    # Base Site
    RewriteBase /
    RewriteCond %{HTTP_HOST} mysite.com
    RewriteRule (.*) mysite_com/$1 [L]

This therefore led to all the urls being generated as such: mysite.com/my_site/whatever rather then mysite.com/whatever

The solution above solved all this... however it messed up all the login because the sessions where not being set and I realized this when I did:

    Debug::dump( Member::currentUser() ); // which returned NULL

Avatar
martimiz

Forum Moderator, 1391 Posts

14 April 2014 at 1:23am

Edited: 14/04/2014 1:23am

OK, I was thinking along the lines of a standard installation. Installing SilverStripe in a subdir and then removing the subdir from the url? I'm not sure it's even really possible - looking at all the other posts - and at the least it seems to be very tricky. Why would you not want to place yopur site in the document root?

Go to Top