mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix 'Uncaught ReferenceError: jQuery is not defined' if jQuery is not included in template.
This commit is contained in:
parent
ff42ad268e
commit
afad65ee71
@ -3,12 +3,12 @@
|
||||
* Log-in form for the "member" authentication method.
|
||||
*
|
||||
* Available extension points:
|
||||
* - "authenticationFailed": Called when login was not successful.
|
||||
* - "authenticationFailed": Called when login was not successful.
|
||||
* Arguments: $data containing the form submission
|
||||
* - "forgotPassword": Called before forgot password logic kicks in,
|
||||
* allowing extensions to "veto" execution by returning FALSE.
|
||||
* - "forgotPassword": Called before forgot password logic kicks in,
|
||||
* allowing extensions to "veto" execution by returning FALSE.
|
||||
* Arguments: $member containing the detected Member record
|
||||
*
|
||||
*
|
||||
* @package framework
|
||||
* @subpackage security
|
||||
*/
|
||||
@ -21,16 +21,16 @@ class MemberLoginForm extends LoginForm {
|
||||
public $loggedInAsField = 'FirstName';
|
||||
|
||||
protected $authenticator_class = 'MemberAuthenticator';
|
||||
|
||||
|
||||
/**
|
||||
* Since the logout and dologin actions may be conditionally removed, it's necessary to ensure these
|
||||
* remain valid actions regardless of the member login state.
|
||||
*
|
||||
* @var array
|
||||
* @config
|
||||
* @config
|
||||
*/
|
||||
private static $allowed_actions = array('dologin', 'logout');
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -59,7 +59,7 @@ class MemberLoginForm extends LoginForm {
|
||||
if(Director::fileExists($customCSS)) {
|
||||
Requirements::css($customCSS);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_REQUEST['BackURL'])) {
|
||||
$backURL = $_REQUEST['BackURL'];
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ class MemberLoginForm extends LoginForm {
|
||||
}
|
||||
if(Security::config()->autologin_enabled) {
|
||||
$fields->push(new CheckboxField(
|
||||
"Remember",
|
||||
"Remember",
|
||||
_t('Member.REMEMBERME', "Remember me next time?")
|
||||
));
|
||||
}
|
||||
@ -124,7 +124,7 @@ class MemberLoginForm extends LoginForm {
|
||||
$js = <<<JS
|
||||
(function() {
|
||||
var el = document.getElementById("MemberLoginForm_LoginForm_Email");
|
||||
if(el && el.focus && (!jQuery || jQuery(el).is(':visible'))) el.focus();
|
||||
if(el && el.focus && (typeof jQuery == 'undefined' || jQuery(el).is(':visible'))) el.focus();
|
||||
})();
|
||||
JS;
|
||||
Requirements::customScript($js, 'MemberLoginFormFieldFocus');
|
||||
@ -137,8 +137,8 @@ JS;
|
||||
parent::getMessageFromSession();
|
||||
if(($member = Member::currentUser()) && !Session::get('MemberLoginForm.force_message')) {
|
||||
$this->message = _t(
|
||||
'Member.LOGGEDINAS',
|
||||
"You're logged in as {name}.",
|
||||
'Member.LOGGEDINAS',
|
||||
"You're logged in as {name}.",
|
||||
array('name' => $member->{$this->loggedInAsField})
|
||||
);
|
||||
}
|
||||
@ -162,11 +162,11 @@ JS;
|
||||
Session::set('SessionForms.MemberLoginForm.Remember', isset($data['Remember']));
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['BackURL'])) $backURL = $_REQUEST['BackURL'];
|
||||
else $backURL = null;
|
||||
if(isset($_REQUEST['BackURL'])) $backURL = $_REQUEST['BackURL'];
|
||||
else $backURL = null;
|
||||
|
||||
if($backURL) Session::set('BackURL', $backURL);
|
||||
|
||||
|
||||
// Show the right tab on failed login
|
||||
$loginLink = Director::absoluteURL($this->controller->Link('login'));
|
||||
if($backURL) $loginLink .= '?BackURL=' . urlencode($backURL);
|
||||
@ -201,7 +201,7 @@ JS;
|
||||
$cp->sessionMessage('Your password has expired. Please choose a new one.', 'good');
|
||||
return $this->controller->redirect('Security/changepassword');
|
||||
}
|
||||
|
||||
|
||||
// Absolute redirection URLs may cause spoofing
|
||||
if(isset($_REQUEST['BackURL']) && $_REQUEST['BackURL'] && Director::is_site_url($_REQUEST['BackURL']) ) {
|
||||
return $this->controller->redirect($_REQUEST['BackURL']);
|
||||
@ -312,7 +312,7 @@ JS;
|
||||
_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'),
|
||||
'bad'
|
||||
);
|
||||
|
||||
|
||||
$this->controller->redirect('Security/lostpassword');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user