X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FFKOAuth1.php;h=26b5637a62676358283c51f4fed890208c2bcf60;hb=ebaf7267440699fd5d34e7399e9d0ff754222e0a;hp=33fdf0ac22732b48002be5bdb5e73642bf711320;hpb=854cc3e47296d4a1b01b893376064cf254d84f79;p=friendica.git diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php index 33fdf0ac22..26b5637a62 100644 --- a/src/Network/FKOAuth1.php +++ b/src/Network/FKOAuth1.php @@ -4,12 +4,9 @@ */ namespace Friendica\Network; -use Friendica\Core\Hook; use Friendica\Core\Logger; -use Friendica\Core\PConfig; -use Friendica\Core\System; use Friendica\Database\DBA; -use Friendica\Util\DateTimeFormat; +use Friendica\DI; use OAuthServer; use OAuthSignatureMethod_HMAC_SHA1; use OAuthSignatureMethod_PLAINTEXT; @@ -32,12 +29,13 @@ class FKOAuth1 extends OAuthServer /** * @param string $uid user id * @return void + * @throws HTTPException\ForbiddenException * @throws HTTPException\InternalServerErrorException */ public function loginUser($uid) { Logger::log("FKOAuth1::loginUser $uid"); - $a = \get_app(); + $a = DI::app(); $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]); if (!DBA::isResult($record)) { @@ -45,31 +43,7 @@ class FKOAuth1 extends OAuthServer header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } - $_SESSION['uid'] = $record['uid']; - $_SESSION['theme'] = $record['theme']; - $_SESSION['mobile-theme'] = PConfig::get($record['uid'], 'system', 'mobile_theme'); - $_SESSION['authenticated'] = 1; - $_SESSION['page_flags'] = $record['page-flags']; - $_SESSION['my_url'] = System::baseUrl() . '/profile/' . $record['nickname']; - $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; - $_SESSION["allow_api"] = true; - $a->user = $record; - - if (strlen($a->user['timezone'])) { - date_default_timezone_set($a->user['timezone']); - $a->timezone = $a->user['timezone']; - } - - $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]); - if (DBA::isResult($contact)) { - $a->contact = $contact; - $a->cid = $contact['id']; - $_SESSION['cid'] = $a->cid; - } - - DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]); - - Hook::callAll('logged_in', $a->user); + DI::auth()->setForUser($a, $record, true); } }