/**
  * Taken from MemberLoginForm::__construct with minor changes
  */
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $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) {
             $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         }
         if (!$actions) {
             $actions = new FieldList(new FormAction('dologin', _t('GoogleAuthenticator.BUTTONLOGIN', "Log in with Google")));
         }
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     // Allow GET method for callback
     $this->setFormMethod('GET', true);
     parent::__construct($controller, $name, $fields, $actions);
 }
 /**
  * EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
  *  - The code has been cleaned up.
  *  - A form action for users who have lost their verification email has been added.
  *
  * We add fields in the constructor so the form is generated when instantiated.
  *
  * @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)
 {
     $email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
     $email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
     $password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
     $authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
     $remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = FieldList::create($authentication_method_field);
         $actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = FieldList::create($authentication_method_field, $email_field, $password_field);
             if (Security::config()->remember_username) {
                 $email_field->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');
                 $email_field->setAttribute('autocomplete', 'off');
             }
         }
         if (!$actions) {
             $actions = FieldList::create(FormAction::create('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>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
         }
     }
     if (isset($_REQUEST['BackURL'])) {
         $fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
     }
     // Reduce attack surface by enforcing POST requests
     $this->setFormMethod('POST', true);
     parent::__construct($controller, $name, $fields, $actions);
     $this->setValidator(RequiredFields::create('Email', 'Password'));
 }
 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);
 }
 /**
  *
  *
  * @return bool
  */
 protected function shouldShowLogoutFields()
 {
     if (!Member::currentUser()) {
         return false;
     }
     if (!Member::logged_in_session_exists()) {
         return false;
     }
     return true;
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
     } else {
     }
     $backURL = isset($_REQUEST['BackURL']) ? $_REQUEST['BackURL'] : Session::get('BackURL');
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     return 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 = null, $actions = null, $checkCurrentUser = true)
 {
     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 {
         $fields = new FieldList(new LiteralField('FacebookLoginIn', "<fb:login-button scope='" . $controller->getFacebookPermissions() . "'></fb:login-button>"));
         $actions = new FieldList(new LiteralField('FacebookLoginLink', "<!-- <a href='" . $controller->getFacebookLoginLink() . "'>" . _t('FacebookLoginForm.LOGIN', 'Login') . "</a> -->"));
     }
     $backURL = isset($_REQUEST['BackURL']) ? $_REQUEST['BackURL'] : Session::get('BackURL');
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     return 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.
  */
 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'])) {
         $_REQUEST['BackURL'] = str_replace("/RegistrationForm", "", $_REQUEST['BackURL']);
         $backURL = $_REQUEST['BackURL'];
     } else {
         if (strpos(Session::get('BackURL'), "/RegistrationForm") > 0) {
             Session::set('BackURL', str_replace("/RegistrationForm", "", Session::get('BackURL')));
         }
         $backURL = str_replace("/RegistrationForm", "", 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::get_unique_identifier_field());
             $fields = new FieldList(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 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>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verifyemail">' . _t('EmailVerifiedMember.BUTTONRESENDEMAIL', "I've lost my verification email") . '</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
     				(function() {
     					var el = document.getElementById("MemberLoginForm_LoginForm_Email");
     					if(el && el.focus) el.focus();
     				})();
     JS
     			);
     		}*/
 }
예제 #9
0
    /**
     * 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), new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password')));
                if (Security::config()->autologin_enabled) {
                    $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?")));
                }
            }
            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
        Requirements::customScript(<<<JS
\t\t\t(function() {
\t\t\t\tvar el = document.getElementById("MemberLoginForm_LoginForm_Email");
\t\t\t\tif(el && el.focus) el.focus();
\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);
 }