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 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-155 Add a new accountServiceAccountUpdatedHook and accountServiceAccountDeletedHook
- Fix FLEXIAPI-153 Add phone and email to be changed in the Activity panel - Fix FLEXIAPI-153 Add phone and email to be changed in the Activity panel
- Fix FLEXIAPI-151 Migrate to hCaptcha - Fix FLEXIAPI-151 Migrate to hCaptcha

View file

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

View file

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

62
flexiapi/composer.lock generated
View file

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

View file

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

View file

@ -14,11 +14,40 @@
@include('admin.account.parts.tabs') @include('admin.account.parts.tabs')
@if ($account->recoveryCodes->isNotEmpty()) @if ($account->accountCreationToken)
<h3>Account Creation Token</h3>
<table class="third"> <table class="third">
<thead> <thead>
<tr> <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>Created</th>
<th>Used</th> <th>Used</th>
<th>IP</th> <th>IP</th>
@ -44,10 +73,11 @@
@endif @endif
@if ($account->phoneChangeCodes->isNotEmpty()) @if ($account->phoneChangeCodes->isNotEmpty())
<h3>Phone Change requests</h3>
<table class="third"> <table class="third">
<thead> <thead>
<tr> <tr>
<th>Phone Change requests</th> <th>Phone</th>
<th>Created</th> <th>Created</th>
<th>Used</th> <th>Used</th>
<th>IP</th> <th>IP</th>
@ -73,10 +103,11 @@
@endif @endif
@if ($account->emailChangeCodes->isNotEmpty()) @if ($account->emailChangeCodes->isNotEmpty())
<h3>Email Change requests</h3>
<table class="third"> <table class="third">
<thead> <thead>
<tr> <tr>
<th>Email Change requests</th> <th>Email</th>
<th>Created</th> <th>Created</th>
<th>Used</th> <th>Used</th>
<th>IP</th> <th>IP</th>
@ -102,10 +133,11 @@
@endif @endif
@if ($account->provisioningTokens->isNotEmpty()) @if ($account->provisioningTokens->isNotEmpty())
<h3>Provisioning tokens</h3>
<table class="third"> <table class="third">
<thead> <thead>
<tr> <tr>
<th>Provisioning Tokens</th> <th>Token</th>
<th>Created</th> <th>Created</th>
<th>Used</th> <th>Used</th>
<th>IP</th> <th>IP</th>

View file

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