/** * Returns an instance of this class * * @param Controller $controller * @param string $name */ public function __construct($controller, $name) { $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class))); $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button'))); // Taken from MemberLoginForm if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } elseif (Session::get('BackURL')) { $backURL = Session::get('BackURL'); } if (isset($backURL)) { // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } } // optionally include requirements {@see /realme/_config/config.yml} if ($this->config()->include_jquery) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); } if ($this->config()->include_javascript) { Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js"); } if ($this->config()->include_css) { Requirements::css(REALME_MODULE_PATH . "/css/realme.css"); } parent::__construct($controller, $name, $fields, $actions); }
public function __construct($controller, $method, $fields = null, $actions = null, $checkCurrentUser = true) { if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); if (Security::$autologin_enabled) { $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME'), Session::get('SessionForms.LinkedinLoginForm.Remember'), $this)); } } if (!$actions) { $actions = new FieldSet(new ImageFormAction('dologin', 'Sign in with LinkedIn', 'linkedin/Images/linkedin.png')); } } if (!empty($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $method, $fields, $actions); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $this->authenticator_class = 'OpenIDAuthenticator'; Requirements::themedCSS('openid_login'); if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUserID()) { $fields = new FieldSet(); $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER'))); } else { if (!$fields) { $fields = new FieldSet(new LiteralField("OpenIDDescription", _t('OpenIDLoginForm.DESC', '<div id="OpenIDDescription"><p>OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account. For more information visit <a href="http://openid.net">openid.net</a>.</p></div> ')), new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("OpenIDURL", _t('OpenIDLoginForm.URL', "OpenID URL"), Session::get('SessionForms.OpenIDLoginForm.OpenIDURL'), null, $this), new CheckboxField("Remember", _t('Member.REMEMBERME'), Session::get('SessionForms.OpenIDLoginForm.Remember'), $this)); } if (!$actions) { $actions = new FieldSet(new FormAction("dologin", _t('Member.BUTTONLOGIN'))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $name, $fields, $actions); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $this->authenticator_class = 'MemberAuthenticator'; $customCSS = project() . '/css/member_login.css'; if (Director::fileExists($customCSS)) { Requirements::css($customCSS); } if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUserID()) { $fields = new FieldSet(); $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", _t('Member.EMAIL'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new EncryptField("Password", _t('Member.PASSWORD'), null, $this), new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?"), Session::get('SessionForms.MemberLoginForm.Remember'), $this)); } if (!$actions) { $actions = new FieldSet(new FormAction("dologin", _t('Member.BUTTONLOGIN', "Log in")), new FormAction("forgotPassword", _t('Member.BUTTONLOSTPASSWORD', "I've lost my password"))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $name, $fields, $actions); }
public function __construct($controller, $name) { if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } $fields = new FieldList(array(new CheckboxField('Remember', _t('SalesforceAuth.REMEMBER_LOGIN', 'Remember login details?')), new HiddenField('AuthenticationMethod', null, 'SalesforceAuthenticator'), new HiddenField('BackURL', null, $backURL))); $actions = new FieldList(array(new FormAction('dologin', _t('SalesforceAuth.LOGIN_WITH_SALESFORCE', 'Login with Salesforce')))); parent::__construct($controller, $name, $fields, $actions); }
public function __construct(Controller $controller, $name) { // Set default fields $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), HiddenField::create('tempid', null, $controller->getRequest()->requestVar('tempid')), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')), LiteralField::create('forgotPassword', sprintf('<p id="ForgotPassword"><a href="%s" target="_top">%s</a></p>', $this->getExternalLink('lostpassword'), _t('CMSMemberLoginForm.BUTTONFORGOTPASSWORD', "Forgot password?")))); if (Security::config()->autologin_enabled) { $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?"))); } // Determine returnurl to redirect to parent page $logoutLink = $this->getExternalLink('logout'); if ($returnURL = $controller->getRequest()->requestVar('BackURL')) { $logoutLink = Controller::join_links($logoutLink, '?BackURL=' . urlencode($returnURL)); } // Make actions $actions = new FieldList(FormAction::create('dologin', _t('CMSMemberLoginForm.BUTTONLOGIN', "Log back in")), LiteralField::create('doLogout', sprintf('<p id="doLogout"><a href="%s" target="_top">%s</a></p>', $logoutLink, _t('CMSMemberLoginForm.BUTTONLOGOUT', "Log out")))); parent::__construct($controller, $name, $fields, $actions); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered * @param string $authenticatorClassName Name of the authenticator class that this form uses. */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { // This is now set on the class directly to make it easier to create subclasses // $this->authenticator_class = $authenticatorClassName; $customCSS = project() . '/css/member_login.css'; if (Director::fileExists($customCSS)) { Requirements::css($customCSS); } if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $label = singleton('Member')->fieldLabel(Member::get_unique_identifier_field()); $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password'))); if (Security::$autologin_enabled) { $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?"))); } } if (!$actions) { $actions = new FieldSet(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>')); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $name, $fields, $actions); // Focus on the email input when the page is loaded // Only include this if other form JS validation is enabled if ($this->getValidator()->getJavascriptValidationHandler() != 'none') { Requirements::customScript(<<<JS \t\t\t\t(function() { \t\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_Email"); \t\t\t\t\tif(el && el.focus) el.focus(); \t\t\t\t})(); JS ); } }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered * @param string $authenticatorClassName Name of the authenticator class that this form uses. */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { // This is now set on the class directly to make it easier to create subclasses // $this->authenticator_class = $authenticatorClassName; if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } $member = Member::currentUser(); $label = singleton('Member')->fieldLabel(Member::get_unique_identifier_field()); if ($checkCurrentUser && $member) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", $member->FirstName), new TextField("SurnameSignup", "Achternaam", $member->Surname), new TextField("EmailSignup", $label, $member->Email), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password'))); $actions = new FieldSet(new FormAction("createorupdateaccount", _t('Member.UPDATEDETAILS', "Update your details")), new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("FirstNameSignup", "Voornaam", Session::get('SessionForms.MemberLoginFormWithSignup.FirstNameSignup'), null, $this), new TextField("SurnameSignup", "Achternaam", Session::get('SessionForms.MemberLoginFormWithSignup.SurnameSignup'), null, $this), new TextField("EmailSignup", $label, Session::get('SessionForms.MemberLoginFormWithSignup.EmailSignup'), null, $this), new PasswordField("PasswordSignup", _t('Member.PASSWORD', 'Password'))); if (Security::$autologin_enabled) { $fields->push(new CheckboxField("RememberSignup", _t('Member.REMEMBERME', "Remember me next time?"))); } } if (!$actions) { $actions = new FieldSet(new FormAction('createorupdateaccount', _t('Member.BUTTONCREATEACCOUNT', "Create account"))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } $requiredFields = parent::__construct($controller, $name, $fields, $actions); $validator = new RequiredFields(array("EmailSignup", "FirstNameSignup", "SurnameSignup", "PasswordSignup")); $validator->setForm($this); $this->validator = $validator; // Focus on the email input when the page is loaded // Only include this if other form JS validation is enabled if ($this->getValidator()->getJavascriptValidationHandler() != 'none') { Requirements::customScript(<<<JS \t\t\t\t(function() { \t\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_EmailSignup"); \t\t\t\t\tif(el && el.focus) el.focus(); \t\t\t\t})(); JS ); } }
public function __construct($controller, $method, $fields = null, $actions = null, $checkCurrentUser = true) { if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } $member = Member::currentUser(); $removeField = ""; if ($member) { $removeField = new ReadonlyField('FacebookButton', 'Facebook', $member->getFacebookButton()); $removeField->dontEscape = true; } if ($checkCurrentUser && $member && Member::logged_in_session_exists()) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); if (!$member->FacebookID) { $fields->push(new LiteralField("FacebookAddExplanation", "<p class=\"message good\">You are already logged in but you can connect your Facebook account to your account with us.</p> ")); } $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $fields = new FieldSet(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); if (Security::$autologin_enabled) { $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', 'Remember me next time?'), Session::get('SessionForms.FacebookLoginForm.Remember'), $this)); } } if (!$actions) { $actions = new FieldSet(new FormAction('dologin', 'Sign in with Facebook')); } } if (!empty($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } if ($removeField) { $actions->push($removeField); } parent::__construct($controller, $method, $fields, $actions); }
/** * Constructor * * @param Controller $controller * @param string $name method on the $controller * @param FieldList $fields * @param FieldList $actions * @param bool $checkCurrentUser - show logout button if logged in */ public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $backURL = Session::get('BackURL'); if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } if ($checkCurrentUser && $this->shouldShowLogoutFields()) { $fields = new FieldList(array(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this))); $actions = new FieldList(array(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")))); } else { if (!$fields) { $fields = new FieldList(array(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this))); } if (!$actions) { $actions = new FieldList(array(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")))); } } if ($backURL) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } $this->setFormMethod('POST', true); parent::__construct($controller, $name, $fields, $actions); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldList|FormField $fields All of the fields in the form - a * {@link FieldList} of {@link FormField} * objects. * @param FieldList|FormAction $actions All of the action buttons in the * form - a {@link FieldList} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { $this->authenticator_class = 'ExternalAuthenticator'; $customCSS = project() . '/css/external_login.css'; if (Director::fileExists($customCSS)) { Requirements::css($customCSS); } if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUserID()) { $fields = new FieldList(); $actions = new FieldList(new FormAction('logout', _t('ExternalAuthenticator.LogOutIn', 'Log in as someone else')), new HiddenField('AuthenticationMethod', null, $this->authenticator_class, $this)); } else { if (!$fields) { if (!ExternalAuthenticator::getUseAnchor()) { $fields = new FieldList(new HiddenField('AuthenticationMethod', null, $this->authenticator_class, $this), new HiddenField('External_SourceID', 'External_SourceID', 'empty'), new HiddenField('External_Anchor', 'External_Anchor', 'empty'), new TextField('External_MailAddr', _t('ExternalAuthenticator.MailAddr', 'e-Mail address'), Session::get('SessionForms.ExternalLoginForm.External_MailAddr')), new PasswordField('Password', _t('ExternalAuthenticator.Password', 'Password'))); } else { $userdesc = ExternalAuthenticator::getAnchorDesc(); $sources = ExternalAuthenticator::getIDandNames(); $fields = new FieldList(new HiddenField('AuthenticationMethod', null, $this->authenticator_class, $this), new HiddenField('External_MailAddr', 'External_MailAddr', 'empty'), new DropdownField('External_SourceID', _t('ExternalAuthenticator.Sources', 'Authentication sources'), $sources, Session::get('SessionForms.ExternalLoginForm.External_SourceID')), new TextField('External_Anchor', $userdesc, Session::get('SessionForms.ExternalLoginForm.External_Anchor')), new PasswordField('Password', _t('ExternalAuthenticator.Password'))); } if (Security::$autologin_enabled) { $fields->push(new CheckboxField("Remember", _t('ExternalAuthenticator.Remember', 'Remember me next time?'), Session::get('SessionForms.ExternalLoginForm.Remember'), $this)); } } if (!$actions) { $actions = new FieldList(new FormAction('dologin', _t('ExternalAuthenticator.Login', 'Log in'))); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $name, $fields, $actions); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldList|FormField $fields All of the fields in the form - a * {@link FieldList} of {@link FormField} * objects. * @param FieldList|FormAction $actions All of the action buttons in the * form - a {@link FieldList} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered * @param string $authenticatorClassName Name of the authenticator class that this form uses. */ public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { // This is now set on the class directly to make it easier to create subclasses // $this->authenticator_class = $authenticatorClassName; $customCSS = project() . '/css/member_login.css'; if (Director::fileExists($customCSS)) { Requirements::css($customCSS); } if (isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) { $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)); $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if (!$fields) { $label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field); $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), $emailField = new TextField("Email", $label, null, null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password'))); if (Security::config()->remember_username) { $emailField->setValue(Session::get('SessionForms.MemberLoginForm.Email')); } else { // Some browsers won't respect this attribute unless it's added to the form $this->setAttribute('autocomplete', 'off'); $emailField->setAttribute('autocomplete', 'off'); } if (Security::config()->autologin_enabled) { $fields->push(CheckboxField::create("Remember", _t('Member.KEEPMESIGNEDIN', "Keep me signed in"))->setAttribute('title', sprintf(_t('Member.REMEMBERME', "Remember me next time? (for %d days on this device)"), Config::inst()->get('RememberLoginHash', 'token_expiry_days')))); } } if (!$actions) { $actions = new FieldList(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>')); } } if (isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } // Reduce attack surface by enforcing POST requests $this->setFormMethod('POST', true); parent::__construct($controller, $name, $fields, $actions); $this->setValidator(new RequiredFields('Email', 'Password')); // Focus on the email input when the page is loaded $js = <<<JS \t\t\t(function() { \t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_Email"); \t\t\t\tif(el && el.focus && (typeof jQuery == 'undefined' || jQuery(el).is(':visible'))) el.focus(); \t\t\t})(); JS; Requirements::customScript($js, 'MemberLoginFormFieldFocus'); }
public function __construct($controller, $name) { $fields = new FieldList(parent::getField('Email'), parent::getField('Password')); //$email = $fields->dataFieldByName('Email'); //$actions = new FieldList(FormAction::create("login")->setTitle("Log in")); $actions = new FieldList(FormAction::create("login")); parent::__construct($controller, $name, $fields, $actions); }
public function __construct($controller, $name) { parent::__construct($controller, $name, $this->getFields(), $this->getActions()); $this->configureBackURL(); }
/** * Constructor * * @param Controller $controller The parent controller, necessary to * create the appropriate form action tag. * @param string $name The method on the controller that will return this * form object. * @param FieldSet|FormField $fields All of the fields in the form - a * {@link FieldSet} of {@link FormField} * objects. * @param FieldSet|FormAction $actions All of the action buttons in the * form - a {@link FieldSet} of * {@link FormAction} objects * @param bool $checkCurrentUser If set to TRUE, it will be checked if a * the user is currently logged in, and if * so, only a logout button will be rendered * @param string $authenticatorClassName Name of the authenticator class that this form uses. */ function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) { // This is now set on the class directly to make it easier to create subclasses // $this->authenticator_class = $authenticatorClassName; $customCSS = project() . '/css/member_login.css'; if(Director::fileExists($customCSS)) { Requirements::css($customCSS); } // Focus on the email input when the page is loaded Requirements::customScript(" (function($){ $(document).ready(function() { $('#Email input').focus(); }); })(jQuery); "); if(isset($_REQUEST['BackURL'])) { $backURL = $_REQUEST['BackURL']; } else { $backURL = Session::get('BackURL'); } if($checkCurrentUser && Member::currentUserID()) { $fields = new FieldSet(); $actions = new FieldSet(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))); } else { if(!$fields) { $fields = new FieldSet( new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", _t('Member.EMAIL', 'Email'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password')) ); if(Security::$autologin_enabled) { $fields->push(new CheckboxField( "Remember", _t('Member.REMEMBERME', "Remember me next time?") )); } } if(!$actions) { $actions = new FieldSet( new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField( 'forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>' ) ); } } if(isset($backURL)) { $fields->push(new HiddenField('BackURL', 'BackURL', $backURL)); } parent::__construct($controller, $name, $fields, $actions); }