Replace recovery token repository
This commit is contained in:
parent
860b2d890b
commit
706dd6523e
2 changed files with 4 additions and 18 deletions
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Pterodactyl\Repositories\Eloquent;
|
|
||||||
|
|
||||||
use Pterodactyl\Models\RecoveryToken;
|
|
||||||
|
|
||||||
class RecoveryTokenRepository extends EloquentRepository
|
|
||||||
{
|
|
||||||
public function model(): string
|
|
||||||
{
|
|
||||||
return RecoveryToken::class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,10 +6,10 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use PragmaRX\Google2FA\Google2FA;
|
use PragmaRX\Google2FA\Google2FA;
|
||||||
|
use Pterodactyl\Models\RecoveryToken;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Illuminate\Contracts\Encryption\Encrypter;
|
use Illuminate\Contracts\Encryption\Encrypter;
|
||||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||||
use Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository;
|
|
||||||
use Pterodactyl\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid;
|
use Pterodactyl\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid;
|
||||||
|
|
||||||
class ToggleTwoFactorService
|
class ToggleTwoFactorService
|
||||||
|
@ -21,7 +21,6 @@ class ToggleTwoFactorService
|
||||||
private ConnectionInterface $connection,
|
private ConnectionInterface $connection,
|
||||||
private Encrypter $encrypter,
|
private Encrypter $encrypter,
|
||||||
private Google2FA $google2FA,
|
private Google2FA $google2FA,
|
||||||
private RecoveryTokenRepository $recoveryTokenRepository,
|
|
||||||
private UserRepositoryInterface $repository
|
private UserRepositoryInterface $repository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -70,12 +69,12 @@ class ToggleTwoFactorService
|
||||||
$tokens[] = $token;
|
$tokens[] = $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before inserting any new records make sure all of the old ones are deleted to avoid
|
// Before inserting any new records make sure all the old ones are deleted to avoid
|
||||||
// any issues or storing an unnecessary number of tokens in the database.
|
// any issues or storing an unnecessary number of tokens in the database.
|
||||||
$this->recoveryTokenRepository->deleteWhere(['user_id' => $user->id]);
|
$user->recoveryTokens()->delete();
|
||||||
|
|
||||||
// Bulk insert the hashed tokens.
|
// Bulk insert the hashed tokens.
|
||||||
$this->recoveryTokenRepository->insert($inserts);
|
RecoveryToken::query()->insert($inserts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->repository->withoutFreshModel()->update($user->id, [
|
$this->repository->withoutFreshModel()->update($user->id, [
|
||||||
|
|
Loading…
Reference in a new issue