3 * @file src/Network/FKOAuth1.php
5 namespace Friendica\Network;
7 use Friendica\Core\Logger;
8 use Friendica\Database\DBA;
11 use OAuthSignatureMethod_HMAC_SHA1;
12 use OAuthSignatureMethod_PLAINTEXT;
15 * @brief OAuth protocol
17 class FKOAuth1 extends OAuthServer
22 public function __construct()
24 parent::__construct(new FKOAuthDataStore());
25 $this->add_signature_method(new OAuthSignatureMethod_PLAINTEXT());
26 $this->add_signature_method(new OAuthSignatureMethod_HMAC_SHA1());
30 * @param string $uid user id
32 * @throws HTTPException\ForbiddenException
33 * @throws HTTPException\InternalServerErrorException
35 public function loginUser($uid)
37 Logger::log("FKOAuth1::loginUser $uid");
39 $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
41 if (!DBA::isResult($record)) {
42 Logger::log('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), Logger::DEBUG);
43 header('HTTP/1.0 401 Unauthorized');
44 die('This api requires login');
47 DI::auth()->setForUser($a, $record, true);