use DivineOmega\PasswordExposed;
use Exception;
-use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
+use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
*
* @param string $password
* @return string
+ * @throws Exception
*/
public static function hashPassword($password)
{
* @param int $uid
* @param string $password
* @return bool
+ * @throws Exception
*/
public static function updatePassword($uid, $password)
{
+ $password = trim($password);
+
+ if (empty($password)) {
+ throw new Exception(L10n::t('Empty passwords are not allowed.'));
+ }
+
+ if (!Config::get('system', 'disable_password_exposed', false) && self::isPasswordExposed($password)) {
+ throw new Exception(L10n::t('The new password has been exposed in a public data dump, please choose another.'));
+ }
+
+ $allowed_characters = '!"#$%&\'()*+,-./;<=>?@[\]^_`{|}~';
+
+ if (!preg_match('/^[a-z0-9' . preg_quote($allowed_characters, '/') . ']+$/i', $password)) {
+ throw new Exception(L10n::t('The password can\'t contain accentuated letters, white spaces or colons (:)'));
+ }
+
return self::updatePasswordHashed($uid, self::hashPassword($password));
}
* - Create self-contact
* - Create profile image
*
- * @param array $data
- * @return string
- * @throw Exception
+ * @param array $data
+ * @return array
+ * @throws \ErrorException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws Exception
*/
public static function create(array $data)
{
- $a = get_app();
+ $a = \get_app();
$return = ['user' => null, 'password' => ''];
$using_invites = Config::get('system', 'invitation_only');
}
if (!$photo_failure) {
- DBA::update('photo', ['profile' => 1], ['resource-id' => $hash]);
+ Photo::update(['profile' => 1], ['resource-id' => $hash]);
}
}
}
- Addon::callHooks('register_account', $uid);
+ Hook::callAll('register_account', $uid);
$return['user'] = $user;
return $return;
If you ever want to delete your account, you can do so at %3$s/removeme
Thank you and welcome to %2$s.',
- $user['email'], $sitename, $siteurl, $user['username'], $password
+ $user['nickname'], $sitename, $siteurl, $user['username'], $password
));
return notification([
return false;
}
- $a = get_app();
+ $a = \get_app();
Logger::log('Removing user: ' . $uid);