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.

General Questions /

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

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

$LoginForm in SS3.x


Go to End
Reply


3 Posts   552 Views

Avatar
Andre

Community Member, 135 Posts

7 May 2013 at 6:50am

Hi there, I have a short question ragarding the $LoginForm Variable within the Template of SS3.x

On 2.4.x I was able, to set this Variable somewhere within the Template and add the "LoginForm" to the allowed_actions within Page_Controller (Page.php).
The Loginform then appeared on every Page, that wass including the Template with the Variable.
When Using the Loginform and submitting some wrong Data from anywhere else other than /Security/login, I get automatically rediected to /Security/login, which then shows the LoginForm pre populated with my wrong credentials and the correct Error Message.
Instead, when I enter correct credentials from any Page, I get logged in and stay on this Page.

This is a very nice behaviour, which seems to be gone (or changed) on SS3.x

On SS3.x for my Test, I have put the $LoginForm Variable under $Content.
Now (on a plain SS3.x installation) I open for example the "about-us" Page and fill the LoginForm with the correct credentials. Then I got logged in and am still on the about-us Page.
When I try to use some wrong credentials, I do not get directed to /Security/login (like in SS2.4.x), instead I get directed to "Page not Found".
Similar Problem appears, when pressing the "Login as someone else" Button. Then I only see a blank Page (with the following URL http://ss30.test2.local/page-not-found/LoginForm for example).

Anyone any Idea, how to reimplement the previous feature from SS2.4.x? Or was this removed because of some Security Issues?

regards

andre

Avatar
nimesodelta

Community Member, 22 Posts

9 April 2015 at 11:41am

Did you solve this? I'm having the same issues... driving me nuts and happy to pay for some help/advice

Avatar
Nicolaas

Forum Moderator, 220 Posts

10 April 2015 at 1:09pm

Edited: 10/04/2015 1:28pm

Hi

Maybe you could add the following to your Page_Controller:

function MyLoginLink() {
  return "/Security/login/?BackURL=".urlencode($this->Link());
}

You can then add $MyLoginLink to your Page.ss template, or wherever the page_controller is the controller rendering the template.

You will avoid all the issues you describe and you still end up with similar functionality - if I understood you correctly that is ;-)

Nicolaas