Skip to content

Commit

Permalink
Merge branch 'Jexactyl:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kokofixcomputers authored Oct 26, 2024
2 parents 7545012 + e1e6d5a commit f83e509
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
8 changes: 5 additions & 3 deletions resources/scripts/api/account/disableAccountTwoFactor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import http from '@/api/http';

export default (password: string): Promise<void> => {
function disableAccountTwoFactor(password: string): Promise<void> {
return new Promise((resolve, reject) => {
http.delete('/api/client/account/two-factor', { params: { password } })
http.post('/api/client/account/two-factor/disable', { password })
.then(() => resolve())
.catch(reject);
});
};
}

export default disableAccountTwoFactor;
2 changes: 1 addition & 1 deletion resources/views/admin/nodes/view/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div>
<select name="location_id" class="form-control">
@foreach($locations as $location)
<option value="{{ $location->id }}" {{ (old('location_id', $node->location_id) === $location->id) ? 'selected' : '' }}>{{ $location->long }} ({{ $location->short }})</option>
<option value="{{ $location->id }}" {{ (((int) old('location_id', $node->location_id)) === $location->id) ? 'selected' : '' }}>{{ $location->long }} ({{ $location->short }})</option>
@endforeach
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/users/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@include('partials/admin.users.nav', ['activeTab' => 'overview', 'user' => $user])

@section('title')
Manager User: {{ $user->username }}
Manage User: {{ $user->username }}
@endsection

@section('content-header')
Expand Down
2 changes: 1 addition & 1 deletion routes/api-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Route::get('/', [Client\AccountController::class, 'index'])->name('api:client.account');
Route::get('/two-factor', [Client\TwoFactorController::class, 'index']);
Route::post('/two-factor', [Client\TwoFactorController::class, 'store']);
Route::delete('/two-factor', [Client\TwoFactorController::class, 'delete']);
Route::post('/two-factor/disable', [Client\TwoFactorController::class, 'delete']);
});

Route::get('/logs', [Client\AccountLogController::class, 'index'])->withoutMiddleware(RequireTwoFactorAuthentication::class);
Expand Down
22 changes: 11 additions & 11 deletions tests/Integration/Api/Client/TwoFactorControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TwoFactorControllerTest extends ClientApiIntegrationTestCase
*/
public function testTwoFactorImageDataIsReturned()
{
/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => false]);

$this->assertFalse($user->use_totp);
Expand All @@ -41,7 +41,7 @@ public function testTwoFactorImageDataIsReturned()
*/
public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
{
/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => true]);

$response = $this->actingAs($user)->getJson('/api/client/account/two-factor');
Expand All @@ -56,7 +56,7 @@ public function testErrorIsReturnedWhenTwoFactorIsAlreadyEnabled()
*/
public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
{
/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => false]);

$this->actingAs($user)
Expand All @@ -73,7 +73,7 @@ public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
*/
public function testTwoFactorCanBeEnabledOnAccount()
{
/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => false]);

// Make the initial call to get the account setup for 2FA.
Expand All @@ -82,7 +82,7 @@ public function testTwoFactorCanBeEnabledOnAccount()
$user = $user->refresh();
$this->assertNotNull($user->totp_secret);

/** @var \PragmaRX\Google2FA\Google2FA $service */
/** @var Google2FA $service */
$service = $this->app->make(Google2FA::class);

$secret = decrypt($user->totp_secret);
Expand Down Expand Up @@ -129,18 +129,18 @@ public function testTwoFactorCanBeDisabledOnAccount()
{
Carbon::setTestNow(Carbon::now());

/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => true]);

$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
$response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'invalid',
]);

$response->assertStatus(Response::HTTP_BAD_REQUEST);
$response->assertJsonPath('errors.0.code', 'BadRequestHttpException');
$response->assertJsonPath('errors.0.detail', 'The password provided was not valid.');

$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
$response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'password',
]);

Expand All @@ -160,10 +160,10 @@ public function testNoErrorIsReturnedIfTwoFactorIsNotEnabled()
{
Carbon::setTestNow(Carbon::now());

/** @var \Jexactyl\Models\User $user */
/** @var User $user */
$user = User::factory()->create(['use_totp' => false]);

$response = $this->actingAs($user)->deleteJson('/api/client/account/two-factor', [
$response = $this->actingAs($user)->postJson('/api/client/account/two-factor/disable', [
'password' => 'password',
]);

Expand Down Expand Up @@ -196,7 +196,7 @@ public function testDisablingTwoFactorRequiresValidPassword()
$user = User::factory()->create(['use_totp' => true]);

$this->actingAs($user)
->deleteJson('/api/client/account/two-factor', [
->postJson('/api/client/account/two-factor/disable', [
'password' => 'foo',
])
->assertStatus(Response::HTTP_BAD_REQUEST)
Expand Down

0 comments on commit f83e509

Please sign in to comment.