User update fix
Change-Id: I9324f8dab9b9b7543e6bae6a3828485e056b7192 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
cb8b5a22cb
commit
af33b9fece
@ -14,6 +14,8 @@
|
||||
use Auth\Group;
|
||||
use Auth\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class UserFactory
|
||||
* @package App\libs\Auth\Factories
|
||||
@ -157,7 +159,7 @@ final class UserFactory
|
||||
if(isset($payload['public_profile_show_email']))
|
||||
$user->setPublicProfileShowEmail(boolval($payload['public_profile_show_email']));
|
||||
|
||||
if(isset($payload['email_verified']) && $payload['email_verified'] == true && !$user->isEmailVerified())
|
||||
if(isset($payload['email_verified']) && boolval($payload['email_verified']) === true && !$user->isEmailVerified())
|
||||
$user->verifyEmail();
|
||||
|
||||
return $user;
|
||||
|
@ -813,8 +813,14 @@ class User extends BaseEntity
|
||||
*/
|
||||
public function getPic(): string
|
||||
{
|
||||
if(!empty($this->pic)){
|
||||
return Storage::disk('swift')->url(sprintf("%s/%s", self::getProfilePicFolder(), $this->pic));
|
||||
try {
|
||||
if (!empty($this->pic)) {
|
||||
return Storage::disk('swift')->url(sprintf("%s/%s", self::getProfilePicFolder(), $this->pic));
|
||||
}
|
||||
return $this->getGravatarUrl();
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
Log::warning($ex);
|
||||
}
|
||||
return $this->getGravatarUrl();
|
||||
}
|
||||
@ -1476,6 +1482,7 @@ SQL;
|
||||
public function verifyEmail()
|
||||
{
|
||||
if (!$this->email_verified) {
|
||||
Log::debug(sprintf("User::verifyEmail verifying email %s", $this->email));
|
||||
$this->email_verified = true;
|
||||
$this->spam_type = self::SpamTypeHam;
|
||||
$this->active = true;
|
||||
@ -1564,15 +1571,16 @@ SQL;
|
||||
*/
|
||||
public function preUpdate(PreUpdateEventArgs $args)
|
||||
{
|
||||
if($this->spam_type != self::SpamTypeNone &&
|
||||
!$args->hasChangedField("active") &&
|
||||
($args->hasChangedField("bio") || $args->hasChangedField("email"))) {
|
||||
// enqueue user for spam re checker
|
||||
$this->resetSpamTypeClassification();
|
||||
Event::fire(new UserSpamStateUpdated($this->getId()));
|
||||
}
|
||||
if($args->hasChangedField("email")) {
|
||||
// record email change
|
||||
if($this->spam_type != self::SpamTypeNone ){
|
||||
if($args->hasChangedField("active")) return;
|
||||
$bio_changed = $args->hasChangedField("bio") && !empty($args->getNewValue('bio'));
|
||||
$email_changed = $args->hasChangedField("email");
|
||||
if( $bio_changed|| $email_changed) {
|
||||
// enqueue user for spam re checker
|
||||
Log::warning(sprintf("User::preUpdate user %s was marked for spam type reclasification.", $this->email));
|
||||
$this->resetSpamTypeClassification();
|
||||
Event::fire(new UserSpamStateUpdated($this->getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user