Merge pull request #9552 from annando/zero-user
Avoid problems with uid=0
This commit is contained in:
commit
10a4802d81
|
@ -342,7 +342,7 @@ function ping_init(App $a)
|
||||||
array_walk($notifications, function (&$notification) {
|
array_walk($notifications, function (&$notification) {
|
||||||
if (empty($notification['photo'])) {
|
if (empty($notification['photo'])) {
|
||||||
$contact = Contact::getByURL($notification['url'], false, ['micro', 'id', 'avatar']);
|
$contact = Contact::getByURL($notification['url'], false, ['micro', 'id', 'avatar']);
|
||||||
$notification['photo'] = Contact::getMicro($contact, $notif['photo']);
|
$notification['photo'] = Contact::getMicro($contact, $notification['photo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification['timestamp'] = DateTimeFormat::local($notification['date']);
|
$notification['timestamp'] = DateTimeFormat::local($notification['date']);
|
||||||
|
|
|
@ -166,7 +166,7 @@ class Profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = User::getOwnerDataById($user['uid'], false);
|
$profile = !empty($user['uid']) ? User::getOwnerDataById($user['uid'], false) : [];
|
||||||
|
|
||||||
if (empty($profile) && empty($profiledata)) {
|
if (empty($profile) && empty($profiledata)) {
|
||||||
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
|
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
|
||||||
|
|
|
@ -264,7 +264,7 @@ class User
|
||||||
*/
|
*/
|
||||||
public static function getById($uid, array $fields = [])
|
public static function getById($uid, array $fields = [])
|
||||||
{
|
{
|
||||||
return DBA::selectFirst('user', $fields, ['uid' => $uid]);
|
return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ class FKOAuth1 extends OAuthServer
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
$record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
|
$record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
|
||||||
|
|
||||||
if (!DBA::isResult($record)) {
|
if (!DBA::isResult($record) || empty($uid)) {
|
||||||
Logger::info('FKOAuth1::loginUser failure', ['server' => $_SERVER]);
|
Logger::info('FKOAuth1::loginUser failure', ['server' => $_SERVER]);
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
die('This api requires login');
|
die('This api requires login');
|
||||||
|
|
Loading…
Reference in a new issue