DONE: replace email verification by link instead of otp
This commit is contained in:
@@ -12,7 +12,6 @@ use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
use Modules\Auth\Entities\User;
|
||||
use Modules\Role\Entities\Role;
|
||||
use Modules\User\Notifications\UserActivationNotification;
|
||||
use Modules\Auth\Services\EmailVerificationOtpService;
|
||||
use Exception;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
@@ -54,38 +53,6 @@ class CreateNewUser implements CreatesNewUsers
|
||||
$user->assignRole($role);
|
||||
}
|
||||
|
||||
app(EmailVerificationOtpService::class)->send($user);
|
||||
|
||||
// Send notification to admins if user requires activation
|
||||
if ($user->status === 'pending') {
|
||||
$this->notifyAdminsForActivation($user);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify admins about new user requiring activation
|
||||
*/
|
||||
private function notifyAdminsForActivation(User $newUser): void
|
||||
{
|
||||
try {
|
||||
$adminRoles = ['PENTADBIR', 'PS 2 KJC', 'PS 2 ALAT'];
|
||||
|
||||
// Get users with specific roles plus admins (PENTADBIR and DEVELOPER)
|
||||
$adminUsers = $this->getUsersWithRolesAndAdmins($adminRoles);
|
||||
|
||||
$sender = auth()->user() ?? $newUser; // Use current user as sender, or new user if no auth
|
||||
|
||||
foreach ($adminUsers as $admin) {
|
||||
try {
|
||||
$admin->notify(new UserActivationNotification($newUser, $sender));
|
||||
} catch (Exception $e) {
|
||||
Log::error('Failed to send user activation notification: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Log::error('Failed to notify admins for user activation: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user