use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
-use Friendica\Model\Photo;
use Friendica\Model\TwoFactor\AppSpecificPassword;
use Friendica\Object\Image;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Images;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Worker\Delivery;
return DBA::selectFirst('user', $fields, ['uid' => $uid]);
}
+ /**
+ * Returns a user record based on it's GUID
+ *
+ * @param string $guid The guid of the user
+ * @param array $fields The fields to retrieve
+ * @param bool $active True, if only active records are searched
+ *
+ * @return array|boolean User record if it exists, false otherwise
+ * @throws Exception
+ */
+ public static function getByGuid(string $guid, array $fields = [], bool $active = true)
+ {
+ if ($active) {
+ $cond = ['guid' => $guid, 'account_expired' => false, 'account_removed' => false];
+ } else {
+ $cond = ['guid' => $guid];
+ }
+
+ return DBA::selectFirst('user', $fields, $cond);
+ }
+
/**
* @param string $nickname
* @param array $fields
`user`.`page-flags`,
`user`.`account-type`,
`user`.`prvnets`,
- `user`.`account_removed`
+ `user`.`account_removed`,
+ `user`.`hidewall`
FROM `contact`
INNER JOIN `user`
ON `user`.`uid` = `contact`.`uid`
*
* @param string $password
* @return bool
+ * @throws Exception
*/
public static function isPasswordExposed($password)
{
'cacheDirectory' => get_temppath() . '/password-exposed-cache/',
]);
- $PasswordExposedCHecker = new PasswordExposed\PasswordExposedChecker(null, $cache);
+ try {
+ $passwordExposedChecker = new PasswordExposed\PasswordExposedChecker(null, $cache);
+
+ return $passwordExposedChecker->passwordExposed($password) === PasswordExposed\PasswordStatus::EXPOSED;
+ } catch (\Exception $e) {
+ Logger::error('Password Exposed Exception: ' . $e->getMessage(), [
+ 'code' => $e->getCode(),
+ 'file' => $e->getFile(),
+ 'line' => $e->getLine(),
+ 'trace' => $e->getTraceAsString()
+ ]);
- return $PasswordExposedCHecker->passwordExposed($password) === PasswordExposed\PasswordStatus::EXPOSED;
+ return false;
+ }
}
/**
}
}
+ /// @todo Check if this part is really needed. We should have fetched all this data in advance
if (empty($username) || empty($email) || empty($nickname)) {
if ($openid_url) {
if (!Network::isUrlValid($openid_url)) {
$filename = basename($photo);
$img_str = Network::fetchUrl($photo, true);
// guess mimetype from headers or filename
- $type = Image::guessType($photo, true);
+ $type = Images::guessType($photo, true);
$Image = new Image($img_str, $type);
if ($Image->isValid()) {
$Image->scaleToSquare(300);
- $hash = Photo::newResource();
+ $resource_id = Photo::newResource();
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 4);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 4);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(80);
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 5);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 5);
if ($r === false) {
$photo_failure = true;
$Image->scaleDown(48);
- $r = Photo::store($Image, $uid, 0, $hash, $filename, L10n::t('Profile Photos'), 6);
+ $r = Photo::store($Image, $uid, 0, $resource_id, $filename, L10n::t('Profile Photos'), 6);
if ($r === false) {
$photo_failure = true;
}
if (!$photo_failure) {
- Photo::update(['profile' => 1], ['resource-id' => $hash]);
+ Photo::update(['profile' => 1], ['resource-id' => $resource_id]);
}
}
}