4

I'm kinda new to silverstripe, had everything working perfect on my localserver, migrated a remote server, things worked fine at the first glance. The next day, I found can't access the admin page though I have been accessing it just the day before. When I type http://www.mydomain.com/admin i get to the homepage of my site with the following url

http://www.mydomain.com/Security/login?BackURL=%2Fadmin%2Fpages

I have looked into all posts online and kinda got lost since there is no error in the page or any indication what could have possible went wrong overnight.

Please advise!

Thanks,

Joe Saad
  • 1,940
  • 3
  • 22
  • 32

2 Answers2

7

The page redirects to http://www.mydomain.com/Security/login?BackURL=%2Fadmin%2Fpages because you have been logged out and need to log in again.

If you do not see the log in form on this page it may be because you have removed $Form from your page template.

Find your Layout/Page.ss template. It may be located in themes/[your-theme]/templates/Layout/Page.ss.

Check if you have $Form in your template. If not, add it after $Content.

Edit

The jquery.mobile-1.2.0.min.js you are loading is blocking your log in form. What you can do is not load jquery mobile for the security pages. Here is a simple if statement you can wrap around your script include that will load it for every page except the Security pages:

<% if $ID > 0 %>
    <script src="https://s3.amazonaws.com/codiqa-cdn/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<% end_if %>

Otherwise what you could do is only load jquery mobile for mobile devices and not for desktop devices. This should do the same thing.

3dgoo
  • 15,716
  • 6
  • 46
  • 58
  • thanks for the prompt reply. I did as you said. The form now appears, when I enter the credentials, it says Error loading the page. I just placed $Form the first thing in the page, would this really matter? I don't necessarily have $Content in that page, would this matter? – Joe Saad Apr 09 '14 at 21:20
  • As long as $Form is with in the `` and not with in a `
    ` it should be OK. Do you get a Silverstripe error or a browser time out error?
    – 3dgoo Apr 09 '14 at 22:14
  • No! I don't have any error showing. That's why it is very puzzling. The only thing is when I press login i get this "Error Loading Page". The thing is that all this was working yesterday. Today I had to redeploy the entire silverstripe copy that worked yesterday and still it is not working. – Joe Saad Apr 09 '14 at 22:24
  • Strange. Try putting the site in dev mode, calling `dev/build?flush=all` and see if any errors are displayed then. Is there anything in your site error log? – 3dgoo Apr 09 '14 at 22:51
  • I did flush a couple of times.. I got a bit closer by noticing that if I put the original Page.ss file, it works just fine. If I put my modified Page.ss with $Form and other different html structure it just say Error Page Loading when I try login. I have no idea why would HTML changes would cause login to break as it appears to be in this case. I don't know how to get to site error log. Any advice please? Thanks! – Joe Saad Apr 10 '14 at 17:48
  • ok, I almost got things working now. Whenever i get this message "Error Loading Page", I just refresh the page and I find that the silverstripe admin is already logged in now and I can see the CMS. That's interesting. So I'm never able to login the first time, after login I always get this Error message, I refresh and I'm in the CMS. Any ideas? – Joe Saad Apr 10 '14 at 18:33
  • Joe, do you want to put your Page.ss in a [code sharing site](http://pastie.org/) and share the link so we can have a look? – 3dgoo Apr 10 '14 at 23:01
  • sure, here is the link for it: http://pastie.org/private/hnkjwivqee3qppjsv6mjoq#69-70,72-74 I commented where the problem is after hours of investigating, however I don't know how to solve it still. – Joe Saad Apr 11 '14 at 00:41
  • 1
    Hi @JoeSaad, I've updated my answer to address the jquery mobile issue. Give it a try and let me know if it helps. – 3dgoo Apr 13 '14 at 21:33
  • that what was what I resorted on doing, I did however put an if statement <% if $URLSegment == "Security" %> i put all code for the admin which is basically the $Form else which is my home page, I have all my home page code along with the including of the various javascripts. This has worked with me. Please let me know if there is something wrong with what i have done here. – Joe Saad Apr 15 '14 at 16:44
1

Set your site in dev mode by adding Director::set_environment_type('dev'); to your mysite/_config.php. Then run a dev/build.

Sometimes when migrating I experience that the baseurl is the old baseurl. A dev/build fix this.

  • It's worth a shot. I've experienced this problem with several sites migrated from our test environment to production. – Marius Engen Haugen Apr 11 '14 at 07:17
  • I already have Director::set_enviornment_type('dev') and built man times. Looks to me that I can see an error in the console upon attempting to login as admin it says NetworkError: 400 Bad Request - http://www.mydomain.com/admin/pages yet when I refresh the page, i see the admin is now logged in and I can see the CMS. The jquery mobile library seems to be messing with the form as in the code i highlighted, since when i remove the library from the ss, it works fine. – Joe Saad Apr 11 '14 at 15:29