Fix FLEXIAPI-280 Ensure that the foreign external_accounts key is handling delete on cascade

This commit is contained in:
Timothée Jaussoin 2025-03-25 14:50:55 +00:00
parent 7cb63f3e51
commit deeea0ddb6
3 changed files with 13 additions and 11 deletions

View file

@ -160,13 +160,12 @@ class AccountService
$account->setRole($request->get('role')); $account->setRole($request->get('role'));
} }
if (!$request->api && $request->has('activated')) { $account->activated = !$request->api
$account->activated = $request->get('activated') == 'true'; && $request->has('activated')
} && in_array($request->get('activated'), ['true', 'on']);
$account->blocked = !$request->api
if (!$request->api && $request->has('blocked')) { && $request->has('blocked')
$account->blocked = in_array($request->get('blocked'), ['true', 'on']); && in_array($request->get('blocked'), ['true', 'on']);
}
if ($request->get('password')) { if ($request->get('password')) {
$account->updatePassword( $account->updatePassword(

View file

@ -19,9 +19,9 @@ return new class extends Migration
$table->string('outbound_proxy', 64)->nullable(); $table->string('outbound_proxy', 64)->nullable();
$table->string('protocol', 4)->default('UDP'); $table->string('protocol', 4)->default('UDP');
$table->integer('account_id')->unsigned()->nullable(); $table->integer('account_id')->unsigned();
$table->foreign('account_id')->references('id') $table->foreign('account_id')->references('id')
->on('accounts')->onDelete('set null'); ->on('accounts')->onDelete('cascade');
$table->timestamps(); $table->timestamps();
}); });

View file

@ -26,7 +26,6 @@
<header> <header>
<h1><i class="ph">users</i> {{ __('Create') }}</h1> <h1><i class="ph">users</i> {{ __('Create') }}</h1>
<a href="{{ route('admin.account.index') }}" class="btn btn-secondary oppose">{{ __('Cancel') }}</a> <a href="{{ route('admin.account.index') }}" class="btn btn-secondary oppose">{{ __('Cancel') }}</a>
<input form="create_edit" class="btn" type="submit" value="{{ __('Create') }}">
</header> </header>
@endif @endif
@ -124,7 +123,11 @@
@endif @endif
<div class="large"> <div class="large">
<input class="btn" type="submit" value="{{ __('Update') }}"> @if ($account->id)
<input class="btn" type="submit" value="{{ __('Update') }}">
@else
<input form="create_edit" class="btn" type="submit" value="{{ __('Create') }}">
@endif
</div> </div>
</form> </form>