Remove invalid calls to the Settings facade

This commit is contained in:
Bubka 2023-03-15 16:26:32 +01:00
parent 4d8180a8c1
commit 82717077be
3 changed files with 12 additions and 11 deletions

View File

@ -2,7 +2,6 @@
namespace App\Http\Controllers\Auth;
use App\Facades\Settings;
use App\Http\Controllers\Controller;
use App\Http\Requests\WebauthnRenameRequest;
use Illuminate\Http\Request;
@ -58,8 +57,9 @@ public function delete(Request $request, $credential)
// no more registered device exists.
// See #110
if (blank($user->webAuthnCredentials()->WhereEnabled()->get())) {
Settings::delete('useWebauthnOnly');
Log::notice('No Webauthn credential enabled, Webauthn settings reset to default');
$request->user()->preferences['useWebauthnOnly'] = false;
$request->user()->save();
}
Log::info('Security device deleted');

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers\Auth;
use App\Extensions\WebauthnCredentialBroker;
use App\Facades\Settings;
use App\Http\Controllers\Controller;
use App\Http\Requests\WebauthnRecoveryRequest;
use Illuminate\Auth\AuthenticationException;
@ -52,7 +51,8 @@ function ($user) use ($request) {
if ($this->shouldRevokeAllCredentials($request)) {
$user->flushCredentials();
}
Settings::delete('useWebauthnOnly');
$user->preferences['useWebauthnOnly'] = false;
$user->save();
} else {
throw new AuthenticationException();
}

View File

@ -68,7 +68,10 @@ public function test_update_user_returns_success()
*/
public function test_update_user_in_demo_mode_returns_unchanged_user()
{
Settings::set('isDemoApp', true);
Config::set('2fauth.config.isDemoApp', true);
$name = $this->user->name;
$email = $this->user->email;
$response = $this->actingAs($this->user, 'web-guard')
->json('PUT', '/user', [
@ -78,17 +81,16 @@ public function test_update_user_in_demo_mode_returns_unchanged_user()
])
->assertOk()
->assertExactJson([
'name' => $this->user->name,
'name' => $name,
'id' => $this->user->id,
'email' => $this->user->email,
'email' => $email,
'is_admin' => $this->user->is_admin,
]);
$this->assertDatabaseHas('users', [
'name' => $this->user->name,
'name' => $name,
'id' => $this->user->id,
'email' => $this->user->email,
'is_admin' => $this->user->is_admin,
'email' => $email,
]);
}
@ -170,7 +172,6 @@ public function test_delete_user_returns_success()
public function test_delete_user_in_demo_mode_returns_unauthorized()
{
Config::set('2fauth.config.isDemoApp', true);
Settings::set('isDemoApp', true);
$response = $this->actingAs($this->user, 'web-guard')
->json('DELETE', '/user', [