fix disable tow step confirmation when there is a password

This commit is contained in:
peaklabs-dev
2024-10-22 12:29:48 +02:00
parent c338eef57b
commit 6dfe6a8142
10 changed files with 56 additions and 30 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Livewire; namespace App\Livewire;
use App\Models\InstanceSettings;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@@ -18,10 +19,12 @@ class NavbarDeleteTeam extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
$currentTeam = currentTeam(); $currentTeam = currentTeam();

View File

@@ -2,6 +2,7 @@
namespace App\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use App\Models\InstanceSettings;
use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledDatabaseBackup;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@@ -58,10 +59,12 @@ class BackupEdit extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
try { try {

View File

@@ -2,10 +2,10 @@
namespace App\Livewire\Project\Database; namespace App\Livewire\Project\Database;
use App\Models\InstanceSettings;
use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledDatabaseBackup;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Livewire\Attributes\On;
use Livewire\Component; use Livewire\Component;
class BackupExecutions extends Component class BackupExecutions extends Component
@@ -42,10 +42,12 @@ class BackupExecutions extends Component
public function deleteBackup($executionId, $password) public function deleteBackup($executionId, $password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
$execution = $this->backup->executions()->where('id', $executionId)->first(); $execution = $this->backup->executions()->where('id', $executionId)->first();

View File

@@ -3,6 +3,7 @@
namespace App\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\Application; use App\Models\Application;
use App\Models\InstanceSettings;
use App\Models\LocalFileVolume; use App\Models\LocalFileVolume;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;
use App\Models\ServiceDatabase; use App\Models\ServiceDatabase;
@@ -87,10 +88,12 @@ class FileStorage extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
try { try {

View File

@@ -2,6 +2,7 @@
namespace App\Livewire\Project\Service; namespace App\Livewire\Project\Service;
use App\Models\InstanceSettings;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@@ -49,10 +50,12 @@ class ServiceApplicationView extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
try { try {

View File

@@ -3,6 +3,7 @@
namespace App\Livewire\Project\Shared; namespace App\Livewire\Project\Shared;
use App\Jobs\DeleteResourceJob; use App\Jobs\DeleteResourceJob;
use App\Models\InstanceSettings;
use App\Models\Service; use App\Models\Service;
use App\Models\ServiceApplication; use App\Models\ServiceApplication;
use App\Models\ServiceDatabase; use App\Models\ServiceDatabase;
@@ -91,7 +92,7 @@ class Danger extends Component
public function delete($password) public function delete($password)
{ {
if (isProduction()) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
if (! Hash::check($password, Auth::user()->password)) { if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.'); $this->addError('password', 'The provided password is incorrect.');

View File

@@ -5,7 +5,7 @@ namespace App\Livewire\Project\Shared;
use App\Actions\Application\StopApplicationOneServer; use App\Actions\Application\StopApplicationOneServer;
use App\Actions\Docker\GetContainersStatus; use App\Actions\Docker\GetContainersStatus;
use App\Events\ApplicationStatusChanged; use App\Events\ApplicationStatusChanged;
use App\Jobs\ContainerStatusJob; use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use App\Models\StandaloneDocker; use App\Models\StandaloneDocker;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@@ -119,10 +119,12 @@ class Destination extends Component
public function removeServer(int $network_id, int $server_id, $password) public function removeServer(int $network_id, int $server_id, $password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) { if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) {

View File

@@ -2,6 +2,7 @@
namespace App\Livewire\Project\Shared\Storages; namespace App\Livewire\Project\Shared\Storages;
use App\Models\InstanceSettings;
use App\Models\LocalPersistentVolume; use App\Models\LocalPersistentVolume;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@@ -40,10 +41,12 @@ class Show extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
$this->storage->delete(); $this->storage->delete();

View File

@@ -3,6 +3,7 @@
namespace App\Livewire\Server; namespace App\Livewire\Server;
use App\Actions\Server\DeleteServer; use App\Actions\Server\DeleteServer;
use App\Models\InstanceSettings;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
@@ -16,10 +17,12 @@ class Delete extends Component
public function delete($password) public function delete($password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
try { try {
$this->authorize('delete', $this->server); $this->authorize('delete', $this->server);

View File

@@ -2,6 +2,7 @@
namespace App\Livewire\Team; namespace App\Livewire\Team;
use App\Models\InstanceSettings;
use App\Models\Team; use App\Models\Team;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@@ -77,10 +78,12 @@ class AdminView extends Component
public function delete($id, $password) public function delete($id, $password)
{ {
if (! Hash::check($password, Auth::user()->password)) { if (! InstanceSettings::get('disable_two_step_confirmation')) {
$this->addError('password', 'The provided password is incorrect.'); if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return; return;
}
} }
if (! auth()->user()->isInstanceAdmin()) { if (! auth()->user()->isInstanceAdmin()) {
return $this->dispatch('error', 'You are not authorized to delete users'); return $this->dispatch('error', 'You are not authorized to delete users');