performLogin($data)) { return $this->logInUserAndRedirect($data); } return $this->redirectBackToForm(); } public function redirectBackToForm() { // Redirect back to form $url = $this->addBackURLParam(CMSSecurity::singleton()->Link('login')); return $this->redirect($url); } /** * Redirect the user to the change password form. * * @skipUpgrade * @return HTTPResponse */ protected function redirectToChangePassword() { // Since this form is loaded via an iframe, this redirect must be performed via javascript $changePasswordForm = ChangePasswordForm::create($this->form->getController(), 'ChangePasswordForm'); $changePasswordForm->sessionMessage( _t('SilverStripe\\Security\\Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'), 'good' ); // Get redirect url $changePasswordURL = $this->addBackURLParam(Security::singleton()->Link('changepassword')); $changePasswordURLATT = Convert::raw2att($changePasswordURL); $changePasswordURLJS = Convert::raw2js($changePasswordURL); $message = _t( 'SilverStripe\\Security\\CMSMemberLoginForm.PASSWORDEXPIRED', '

Your password has expired. Please choose a new one.

', 'Message displayed to user if their session cannot be restored', array('link' => $changePasswordURLATT) ); // Redirect to change password page $response = HTTPResponse::create() ->setBody(<< $message PHP ); return $response; } /** * Send user to the right location after login * * @param array $data * @return HTTPResponse */ protected function logInUserAndRedirect($data) { // Check password expiry if (Member::currentUser()->isPasswordExpired()) { // Redirect the user to the external password change form if necessary return $this->redirectToChangePassword(); } // Link to success template $url = CMSSecurity::singleton()->Link('success'); return $this->redirect($url); } }