mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
Add check if _install/install.lock exists before sending registration related emails. Fixes issue #928
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2019-03-08 DariusIII
|
||||
* Fux: Add check if _install/install.lock exists before sending registration related emails. Fixes issue #928
|
||||
* Chg: Replace raw queries in collectionFileCheckStage1 function with query builder counterpart
|
||||
* Chg: Replace raw queries in collectionFileCheckStage2 function with query builder counterpart
|
||||
* Chg: Start replacing raw SQL queries with query builder in ProcessReleases class
|
||||
|
||||
@@ -165,7 +165,7 @@ class InstallNntmux extends Command
|
||||
|
||||
$this->info('Adding admin user to database');
|
||||
try {
|
||||
User::add(config('nntmux.admin_username'), config('nntmux.admin_password'), config('nntmux.admin_email'), 2, '', '', '', '');
|
||||
User::add(config('nntmux.admin_username'), config('nntmux.admin_password'), config('nntmux.admin_email'), 2);
|
||||
User::where('username', config('nntmux.admin_username'))->update(['verified' => 1, 'email_verified_at' => now()]);
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage();
|
||||
|
||||
+1
-10
@@ -746,17 +746,13 @@ class User extends Authenticatable
|
||||
* @return bool|int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function add($userName, $password, $email, $role, $notes, $host, $invites = Invitation::DEFAULT_INVITES, $invitedBy = 0)
|
||||
public static function add($userName, $password, $email, $role, $notes = '', $host = '', $invites = Invitation::DEFAULT_INVITES, $invitedBy = 0)
|
||||
{
|
||||
$password = self::hashPassword($password);
|
||||
if (! $password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$roleData = Role::query()->where('id', $role);
|
||||
$rateLimit = $roleData->value('rate_limit');
|
||||
$roleName = $roleData->value('name');
|
||||
|
||||
$storeips = (int) Settings::settingValue('..storeuserips') === 1 ? $host : '';
|
||||
|
||||
$user = self::create(
|
||||
@@ -766,17 +762,12 @@ class User extends Authenticatable
|
||||
'email' => $email,
|
||||
'host' => $storeips,
|
||||
'roles_id' => $role,
|
||||
'api_token' => md5(Password::getRepository()->createNewToken()),
|
||||
'invites' => $invites,
|
||||
'invitedby' => (int) $invitedBy === 0 ? null : $invitedBy,
|
||||
'userseed' => md5(Str::uuid()->toString()),
|
||||
'notes' => $notes,
|
||||
'rate_limit' => $rateLimit,
|
||||
]
|
||||
);
|
||||
|
||||
$user->assignRole($roleName);
|
||||
|
||||
return $user->id;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace App\Observers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Jobs\SendWelcomeEmail;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use App\Jobs\SendAccountDeletedEmail;
|
||||
use App\Jobs\SendNewRegisteredAccountMail;
|
||||
@@ -21,13 +24,24 @@ class UserServiceObserver
|
||||
*/
|
||||
public function created(User $user)
|
||||
{
|
||||
$roleName = Role::query()->where('id', $user->roles_id)->value('name');
|
||||
$roleData = Role::query()->where('id', $user->roles_id);
|
||||
$rateLimit = $roleData->value('rate_limit');
|
||||
$roleName = $roleData->value('name');
|
||||
$user->assignRole($roleName);
|
||||
SendNewRegisteredAccountMail::dispatch($user);
|
||||
SendWelcomeEmail::dispatch($user);
|
||||
UserVerification::generate($user);
|
||||
$user->update(
|
||||
[
|
||||
'api_token' => md5(Password::getRepository()->createNewToken()),
|
||||
'userseed' => md5(Str::uuid()->toString()),
|
||||
'rate_limit' => $rateLimit,
|
||||
]
|
||||
);
|
||||
if (File::isFile(base_path().'/_install/install.lock')) {
|
||||
SendNewRegisteredAccountMail::dispatch($user);
|
||||
SendWelcomeEmail::dispatch($user);
|
||||
UserVerification::generate($user);
|
||||
|
||||
UserVerification::send($user, 'User email verification required');
|
||||
UserVerification::send($user, 'User email verification required');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user