Skip to content

Commit

Permalink
Fix 'Uncaught ReferenceError: jQuery is not defined' if jQuery is not…
Browse files Browse the repository at this point in the history
… included in template.
  • Loading branch information
timsnadden committed Apr 29, 2014
1 parent ff42ad2 commit afad65e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions security/MemberLoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*
Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
if(Director::fileExists($customCSS)) {
Requirements::css($customCSS);
}

if(isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
Expand Down Expand Up @@ -92,7 +92,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
}
if(Security::config()->autologin_enabled) {
$fields->push(new CheckboxField(
"Remember",
"Remember",
_t('Member.REMEMBERME', "Remember me next time?")
));
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public function __construct($controller, $name, $fields = null, $actions = null,
$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');
Expand All @@ -137,8 +137,8 @@ protected function getMessageFromSession() {
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})
);
}
Expand All @@ -162,11 +162,11 @@ public function dologin($data) {
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);
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function logInUserAndRedirect($data) {
$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']);
Expand Down Expand Up @@ -312,7 +312,7 @@ public function forgotPassword($data) {
_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'),
'bad'
);

$this->controller->redirect('Security/lostpassword');
}
}
Expand Down

0 comments on commit afad65e

Please sign in to comment.