Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/UserAliasObserver.php
Show All 24 Lines | public function creating(UserAlias $alias): bool | ||||
$domain = Domain::where('namespace', $domain)->first(); | $domain = Domain::where('namespace', $domain)->first(); | ||||
if (!$domain) { | if (!$domain) { | ||||
\Log::error("Failed creating alias {$alias->alias}. Domain does not exist."); | \Log::error("Failed creating alias {$alias->alias}. Domain does not exist."); | ||||
return false; | return false; | ||||
} | } | ||||
if ($alias->user) { | |||||
machniak: Maybe we should also check if `$alias->user` is not null. | |||||
if ($alias->user->tenant_id != $domain->tenant_id) { | |||||
\Log::error("Reseller for user '{$alias->user->email}' and domain '{$domain->namespace}' differ."); | |||||
return false; | |||||
} | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Handle the user alias "created" event. | * Handle the user alias "created" event. | ||||
* | * | ||||
* @param \App\UserAlias $alias User email alias | * @param \App\UserAlias $alias User email alias | ||||
* | * | ||||
Show All 37 Lines |
Maybe we should also check if $alias->user is not null.