Fix FLEXIAPI-156 Disable the Phone change web form when PHONE_AUTHENTICATION is disabled

This commit is contained in:
Timothée Jaussoin 2024-04-02 13:57:08 +00:00
parent 75599dd5ab
commit c5f001e337
7 changed files with 105 additions and 50 deletions

View file

@ -2,6 +2,7 @@
v1.5
----
- Fix FLEXIAPI-156 Disable the Phone change web form when PHONE_AUTHENTICATION is disabled
- Fix FLEXIAPI-155 Add a new accountServiceAccountUpdatedHook and accountServiceAccountDeletedHook
- Fix FLEXIAPI-153 Add phone and email to be changed in the Activity panel
- Fix FLEXIAPI-151 Migrate to hCaptcha

View file

@ -247,6 +247,11 @@ class Account extends Authenticatable
return $this->hasMany(ProvisioningToken::class)->latest();
}
public function accountCreationToken()
{
return $this->hasOne(AccountCreationToken::class);
}
public function authTokens()
{
return $this->hasMany(AuthToken::class);

View file

@ -32,9 +32,19 @@ class AccountCreationToken extends Consommable
return $this->hasOne(AccountCreationRequestToken::class, 'acc_creation_token_id');
}
public function account()
{
return $this->belongsTo(Account::class);
}
public function consume()
{
$this->used = true;
$this->save();
}
public function consumed(): bool
{
return $this->used == true;
}
}

62
flexiapi/composer.lock generated
View file

@ -9014,23 +9014,23 @@
"packages-dev": [
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.12.2",
"version": "v3.13.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "43555503052443964ce2c1c1f3b0378e58219eb8"
"reference": "354a42f3e0b083cdd6f9da5a9d1c0c63b074547a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/43555503052443964ce2c1c1f3b0378e58219eb8",
"reference": "43555503052443964ce2c1c1f3b0378e58219eb8",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/354a42f3e0b083cdd6f9da5a9d1c0c63b074547a",
"reference": "354a42f3e0b083cdd6f9da5a9d1c0c63b074547a",
"shasum": ""
},
"require": {
"illuminate/routing": "^9|^10|^11",
"illuminate/session": "^9|^10|^11",
"illuminate/support": "^9|^10|^11",
"maximebf/debugbar": "~1.21.0",
"maximebf/debugbar": "~1.22.0",
"php": "^8.0",
"symfony/finder": "^6|^7"
},
@ -9043,7 +9043,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.10-dev"
"dev-master": "3.13-dev"
},
"laravel": {
"providers": [
@ -9082,7 +9082,7 @@
],
"support": {
"issues": "https://github.com/barryvdh/laravel-debugbar/issues",
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.12.2"
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.0"
},
"funding": [
{
@ -9094,7 +9094,7 @@
"type": "github"
}
],
"time": "2024-03-13T09:50:34+00:00"
"time": "2024-04-01T16:39:30+00:00"
},
{
"name": "composer/pcre",
@ -9169,16 +9169,16 @@
},
{
"name": "composer/xdebug-handler",
"version": "3.0.3",
"version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "ced299686f41dce890debac69273b47ffe98a40c"
"reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c",
"reference": "ced299686f41dce890debac69273b47ffe98a40c",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
"reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
"shasum": ""
},
"require": {
@ -9189,7 +9189,7 @@
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"symfony/phpunit-bridge": "^6.0"
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
},
"type": "library",
"autoload": {
@ -9213,9 +9213,9 @@
"performance"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/xdebug-handler/issues",
"source": "https://github.com/composer/xdebug-handler/tree/3.0.3"
"source": "https://github.com/composer/xdebug-handler/tree/3.0.4"
},
"funding": [
{
@ -9231,7 +9231,7 @@
"type": "tidelift"
}
],
"time": "2022-02-25T21:32:43+00:00"
"time": "2024-03-26T18:29:49+00:00"
},
{
"name": "filp/whoops",
@ -9357,25 +9357,27 @@
},
{
"name": "maximebf/debugbar",
"version": "v1.21.3",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b"
"reference": "d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0b407703b08ea0cf6ebc61e267cc96ff7000911b",
"reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc",
"reference": "d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc",
"shasum": ""
},
"require": {
"php": "^7.1|^8",
"php": "^7.2|^8",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^4|^5|^6|^7"
},
"require-dev": {
"phpunit/phpunit": ">=7.5.20 <10.0",
"dbrekelmans/bdi": "^1",
"phpunit/phpunit": "^8|^9",
"symfony/panther": "^1|^2.1",
"twig/twig": "^1.38|^2.7|^3.0"
},
"suggest": {
@ -9386,7 +9388,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.21-dev"
"dev-master": "1.22-dev"
}
},
"autoload": {
@ -9417,9 +9419,9 @@
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
"source": "https://github.com/maximebf/php-debugbar/tree/v1.21.3"
"source": "https://github.com/maximebf/php-debugbar/tree/v1.22.1"
},
"time": "2024-03-12T14:23:07+00:00"
"time": "2024-04-01T10:44:20+00:00"
},
{
"name": "mockery/mockery",
@ -9740,16 +9742,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.9.0",
"version": "3.9.1",
"source": {
"type": "git",
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
"reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b"
"reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b",
"reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b",
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909",
"reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909",
"shasum": ""
},
"require": {
@ -9816,7 +9818,7 @@
"type": "open_collective"
}
],
"time": "2024-02-16T15:06:51+00:00"
"time": "2024-03-31T21:03:09+00:00"
},
{
"name": "symfony/config",

View file

@ -17,15 +17,18 @@
<a href="{{ route('account.email.change') }}">Change my current account email</a>
</p>
<p>
<i class="material-symbols-outlined">call</i>
@if (!empty($account->phone))
{{ $account->phone }}
@else
No phone yet
@endif
<a href="{{ route('account.phone.change') }}">Change my current account phone</a>
</p>
@if (config('app.phone_authentication'))
<p>
<i class="material-symbols-outlined">call</i>
@if (!empty($account->phone))
{{ $account->phone }}
@else
No phone yet
@endif
<a href="{{ route('account.phone.change') }}">Change my current account phone</a>
</p>
@endif
<p>
<i class="material-symbols-outlined">devices</i>
<a href="{{ route('account.device.index') }}">

View file

@ -14,11 +14,40 @@
@include('admin.account.parts.tabs')
@if ($account->recoveryCodes->isNotEmpty())
@if ($account->accountCreationToken)
<h3>Account Creation Token</h3>
<table class="third">
<thead>
<tr>
<th>Recovery Codes</th>
<th>Code</th>
<th>Created</th>
<th>Used</th>
<th>IP</th>
</tr>
</thead>
<tbody>
<tr @if ($account->accountCreationToken->consumed()) class="disabled crossed" @endif>
<td>****</td>
<td>
{{ $account->accountCreationToken->created_at }}
</td>
<td>
{{ $account->accountCreationToken->created_at != $account->accountCreationToken->updated_at ? $account->accountCreationToken->updated_at : '-' }}
</td>
<td title="{{ $account->accountCreationToken->user_agent }}">
{{ $account->accountCreationToken->ip ? $account->accountCreationToken->ip : '-' }}
</td>
</tr>
</tbody>
</table>
@endif
@if ($account->recoveryCodes->isNotEmpty())
<h3>Recovery Codes</h3>
<table class="third">
<thead>
<tr>
<th>Code</th>
<th>Created</th>
<th>Used</th>
<th>IP</th>
@ -44,10 +73,11 @@
@endif
@if ($account->phoneChangeCodes->isNotEmpty())
<h3>Phone Change requests</h3>
<table class="third">
<thead>
<tr>
<th>Phone Change requests</th>
<th>Phone</th>
<th>Created</th>
<th>Used</th>
<th>IP</th>
@ -73,10 +103,11 @@
@endif
@if ($account->emailChangeCodes->isNotEmpty())
<h3>Email Change requests</h3>
<table class="third">
<thead>
<tr>
<th>Email Change requests</th>
<th>Email</th>
<th>Created</th>
<th>Used</th>
<th>IP</th>
@ -102,10 +133,11 @@
@endif
@if ($account->provisioningTokens->isNotEmpty())
<h3>Provisioning tokens</h3>
<table class="third">
<thead>
<tr>
<th>Provisioning Tokens</th>
<th>Token</th>
<th>Created</th>
<th>Used</th>
<th>IP</th>

View file

@ -106,12 +106,14 @@ Route::group(['middleware' => 'web_panel_enabled'], function () {
Route::post('/', 'store')->name('email.update');
});
Route::prefix('phone')->controller(PhoneController::class)->group(function () {
Route::get('change', 'change')->name('phone.change');
Route::post('change', 'requestChange')->name('phone.request_change');
Route::get('validate', 'validateChange')->name('phone.validate');
Route::post('/', 'store')->name('phone.update');
});
if (config('app.phone_authentication')) {
Route::prefix('phone')->controller(PhoneController::class)->group(function () {
Route::get('change', 'change')->name('phone.change');
Route::post('change', 'requestChange')->name('phone.request_change');
Route::get('validate', 'validateChange')->name('phone.validate');
Route::post('/', 'store')->name('phone.update');
});
}
Route::name('device.')->prefix('devices')->controller(DeviceController::class)->group(function () {
Route::get('/', 'index')->name('index');