X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FLogin.php;h=b9e51da4caf22478d3177bbfb43fce961e03fa85;hb=9ddb6abe08177368744d0f52b1f36a227527a1a1;hp=fe3305a91b8846a893ef279583b41cc14c01563e;hpb=c845415a99ebc348103815a7b2c55b15c75cdd24;p=friendica.git diff --git a/src/Module/Login.php b/src/Module/Login.php index fe3305a91b..b9e51da4ca 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -4,16 +4,15 @@ */ namespace Friendica\Module; +use Exception; use Friendica\BaseModule; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use dba; -use Exception; use LightOpenID; require_once 'boot.php'; @@ -43,7 +42,7 @@ class Login extends BaseModule goaway(self::getApp()->get_baseurl()); } - return self::form(self::getApp()->get_baseurl(), $a->config['register_policy'] != REGISTER_CLOSED); + return self::form(self::getApp()->get_baseurl(), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED); } public static function post() @@ -90,7 +89,8 @@ class Login extends BaseModule // Otherwise it's probably an openid. try { - $openid = new LightOpenID; + $a = get_app(); + $openid = new LightOpenID($a->get_hostname()); $openid->identity = $openid_url; $_SESSION['openid'] = $openid_url; $_SESSION['remember'] = $remember; @@ -134,7 +134,7 @@ class Login extends BaseModule throw new Exception(L10n::t('Login failed.')); } } else { - $record = dba::selectFirst('user', [], + $record = DBA::selectFirst('user', [], ['uid' => User::getIdFromPasswordAuthentication($username, $password)] ); } @@ -175,7 +175,7 @@ class Login extends BaseModule $data = json_decode($_COOKIE["Friendica"]); if (isset($data->uid)) { - $user = dba::selectFirst('user', [], + $user = DBA::selectFirst('user', [], [ 'uid' => $data->uid, 'blocked' => false, @@ -184,7 +184,7 @@ class Login extends BaseModule 'verified' => true, ] ); - if (DBM::is_result($user)) { + if (DBA::isResult($user)) { if ($data->hash != cookie_hash($user)) { logger("Hash for user " . $data->uid . " doesn't fit."); nuke_session(); @@ -211,11 +211,9 @@ class Login extends BaseModule if (isset($_SESSION) && x($_SESSION, 'authenticated')) { if (x($_SESSION, 'visitor_id') && !x($_SESSION, 'uid')) { - $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", - intval($_SESSION['visitor_id']) - ); - if (DBM::is_result($r)) { - self::getApp()->contact = $r[0]; + $contact = DBA::selectFirst('contact', [], ['id' => $_SESSION['visitor_id']]); + if (DBA::isResult($contact)) { + self::getApp()->contact = $contact; } } @@ -230,7 +228,7 @@ class Login extends BaseModule goaway(self::getApp()->get_baseurl()); } - $user = dba::selectFirst('user', [], + $user = DBA::selectFirst('user', [], [ 'uid' => $_SESSION['uid'], 'blocked' => false, @@ -239,7 +237,7 @@ class Login extends BaseModule 'verified' => true, ] ); - if (!DBM::is_result($user)) { + if (!DBA::isResult($user)) { nuke_session(); goaway(self::getApp()->get_baseurl()); } @@ -247,7 +245,7 @@ class Login extends BaseModule // Make sure to refresh the last login time for the user if the user // stays logged in for a long time, e.g. with "Remember Me" $login_refresh = false; - if (!x($_SESSION['last_login_date'])) { + if (empty($_SESSION['last_login_date'])) { $_SESSION['last_login_date'] = DateTimeFormat::utcNow(); } if (strcmp(DateTimeFormat::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) { @@ -265,7 +263,7 @@ class Login extends BaseModule * @param string $return_url The url relative to the base the user should be sent * back to after login completes * @param bool $register If $register == true provide a registration link. - * This will most always depend on the value of $a->config['register_policy']. + * This will most always depend on the value of config.register_policy. * @param array $hiddens optional * * @return string Returns the complete html for inserting into the page