-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * fix: disable email sending in seeder (#273) * fix conflicts * fix conflicts * Fix set password for admin ngo * Set admin email fix * Fix emailing --------- Co-authored-by: Andrei Ioniță <[email protected]>
- Loading branch information
1 parent
4667896
commit 1290e3e
Showing
37 changed files
with
1,348 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Concerns; | ||
|
||
use App\Enums\UserRole; | ||
use App\Notifications\Admin\WelcomeNotification as AdminWelcomeNotification; | ||
use App\Notifications\Ngo\WelcomeNotification; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Str; | ||
|
||
trait MustSetInitialPassword | ||
{ | ||
protected static function bootMustSetInitialPassword(): void | ||
{ | ||
static::creating(function (self $user) { | ||
if (! $user->password) { | ||
$user->password = Hash::make(Str::random(128)); | ||
} | ||
}); | ||
|
||
static::created(function (self $user) { | ||
if (! app()->runningInConsole()) { | ||
$user->sendWelcomeNotification(); | ||
} | ||
}); | ||
} | ||
|
||
public function hasSetPassword(): bool | ||
{ | ||
return ! \is_null($this->password_set_at); | ||
} | ||
|
||
public function markPasswordAsSet(): bool | ||
{ | ||
return $this->forceFill([ | ||
'password_set_at' => $this->freshTimestamp(), | ||
])->save(); | ||
} | ||
|
||
public function sendWelcomeNotification(): void | ||
{ | ||
if ($this->role===UserRole::ngo_admin) | ||
{ | ||
$this->notify(new WelcomeNotification()); | ||
return; | ||
} | ||
$this->notify(new AdminWelcomeNotification()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
app/Filament/Resources/UsersResource/Pages/CreateUsers.php
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.