Found the answer on SS Bits...
http://www.ssbits.com/tutorials/2009/custom-login-form-with-group-based-redirection/
Make sure you read all the comments to get it working in SS 3.x...
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Found the answer on SS Bits...
http://www.ssbits.com/tutorials/2009/custom-login-form-with-group-based-redirection/
Make sure you read all the comments to get it working in SS 3.x...
Hi All,
If you want to embed a generic login form on a page in your CMS, you can hijack the default form used by Security/login.
I do this quite a lot, to gain access to the basic form you will need to add the following functions to your page controller:
class Page_Controller extends ContentController
{
...
private static $allowed_actions = array(
"LoginForm",
"login",
);
/**
* Use this function to direct a user where you want them to go after login
* (currently the root of the site)
*/
public function login()
{
return $this->redirect(Director::absoluteBaseURL());
}
/**
* Get the login form to process according to the submitted data
*
* @return Form
*/
public function LoginForm()
{
$authenticator = Authenticator::get_default_authenticator();
if($authenticator) {
$form = $authenticator::get_login_form($this);
// Use this if you want to use a custom form template
$form->setTemplate('HomeLoginForm');
return $form;
}
throw new Exception('Passed invalid authentication method');
}
...
}
You can add this form to your template by using the $LoginForm variable.
It should work off the bat and load the default login form into your template, if there are any issues give us a shout.