BUG Fix some database errors during dev/build where an auth token exists for the current user

Fixes #3660
This commit is contained in:
Damian Mooyman 2015-03-25 11:34:13 +13:00
parent ed4db4f135
commit 8d6cd1529f

View File

@ -520,11 +520,16 @@ class Member extends DataObject implements TemplateGlobalProvider {
// Don't bother trying this multiple times
self::$_already_tried_to_auto_log_in = true;
if(strpos(Cookie::get('alc_enc'), ':') && !Session::get("loggedInAs")) {
list($uid, $token) = explode(':', Cookie::get('alc_enc'), 2);
$SQL_uid = Convert::raw2sql($uid);
if(strpos(Cookie::get('alc_enc'), ':') === false
|| Session::get("loggedInAs")
|| !Security::database_is_ready()
) {
return;
}
$member = DataObject::get_one("Member", "\"Member\".\"ID\" = '$SQL_uid'");
list($uid, $token) = explode(':', Cookie::get('alc_enc'), 2);
$member = DataObject::get_by_id("Member", $uid);
// check if autologin token matches
if($member) {
@ -555,7 +560,6 @@ class Member extends DataObject implements TemplateGlobalProvider {
$member->extend('memberAutoLoggedIn');
}
}
}
/**
* Logs this member out.