mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 01:58:07 +00:00
Fix FLEXIAPI-337 Generate the provisioning URLs based on the user space
This commit is contained in:
parent
5be36f5bbd
commit
cb5afe3343
16 changed files with 69 additions and 22 deletions
|
|
@ -52,6 +52,8 @@ v2.0
|
|||
- Fix FLEXIAPI-324 Add an app setup wizard page
|
||||
- Fix FLEXIAPI-335 Safari rendering issues with font icons
|
||||
- Fix FLEXIAPI-336 Fix broken ph icons
|
||||
- Fix FLEXIAPI-333 Remove HTML buttons because they cannot be rendered in "old" Outlook versions
|
||||
- Fix FLEXIAPI-337 Generate the provisioning URLs based on the user space
|
||||
|
||||
v1.6
|
||||
----
|
||||
|
|
|
|||
|
|
@ -354,6 +354,34 @@ class Account extends Authenticatable
|
|||
return Space::where('domain', $this->domain)->where('super', true)->exists() && $this->admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provisioning
|
||||
*/
|
||||
|
||||
public function getProvisioningUrlAttribute(): string
|
||||
{
|
||||
return replaceHost(
|
||||
route('provisioning.provision', $this->getProvisioningTokenAttribute()),
|
||||
$this->space->host
|
||||
);
|
||||
}
|
||||
|
||||
public function getProvisioningQrcodeUrlAttribute(): string
|
||||
{
|
||||
return replaceHost(
|
||||
route('provisioning.qrcode', $this->getProvisioningTokenAttribute()),
|
||||
$this->space->host
|
||||
);
|
||||
}
|
||||
|
||||
public function getProvisioningWizardUrlAttribute(): string
|
||||
{
|
||||
return replaceHost(
|
||||
route('provisioning.wizard', $this->getProvisioningTokenAttribute()),
|
||||
$this->space->host
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utils
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ class ClearAccountsTombstones extends Command
|
|||
$this->info($tombstones->count() . ' tombstones deleted');
|
||||
$tombstones->delete();
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info($tombstones->count() . ' tombstones to delete');
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class ClearApiKeys extends Command
|
|||
|
||||
if ($minutes == 0) {
|
||||
$this->info('Expiration time is set to 0, nothing to clear');
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info('Deleting user API Keys unused after ' . $minutes . ' minutes');
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ class ClearUnconfirmed extends Command
|
|||
$accounts->delete();
|
||||
$this->info($count . ' accounts deleted');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info($count . ' accounts to delete');
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,6 @@ class CreateAdminAccount extends Command
|
|||
|
||||
$this->info('Admin test account created: "' . $username . '@' . $domain . '" | Password: "' . $password . '" | API Key: "' . $account->apiKey->key . '" (valid on ' . ($account->apiKey->ip ?? 'any') . ' ip)');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,6 @@ class CreateAdminTest extends Command
|
|||
|
||||
$this->info('API Key updated to: ' . $secret);
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ class SetAdmin extends Command
|
|||
|
||||
if (!$account) {
|
||||
$this->error('Account not found, please use an existing account id');
|
||||
return 1;
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
if ($account->admin) {
|
||||
$this->error('The account is already having the admin role');
|
||||
return 1;
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$account->admin = true;
|
||||
|
|
@ -52,6 +52,6 @@ class SetAdmin extends Command
|
|||
|
||||
$this->info('Account '.$account->identifier.' is now admin');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,14 +44,21 @@ class CreateUpdate extends Command
|
|||
$space->domain = $this->argument('sip_domain');
|
||||
$space->name = $this->argument('name');
|
||||
|
||||
if ($hostSpace = Space::where('host', $this->argument('host'))->first()) {
|
||||
if (!$space->exists && $hostSpace->domain != $space->domain) {
|
||||
$this->error('A Space with this host and a different sip_domain already exists in the database');
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
$space->exists
|
||||
? $this->info('The domain already exists, updating it')
|
||||
: $this->info('A new domain will be created');
|
||||
? $this->info('The space already exists, updating it')
|
||||
: $this->info('A new Space will be created');
|
||||
|
||||
$space->super = (bool)$this->option('super');
|
||||
$space->super
|
||||
? $this->info('Set as a super domain')
|
||||
: $this->info('Set as a normal domain');
|
||||
? $this->info('Set as a super Space')
|
||||
: $this->info('Set as a normal Space');
|
||||
|
||||
$space->save();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ class ImportConfigurationFromDotEnv extends Command
|
|||
|
||||
if (!$space) {
|
||||
$this->error('The space cannot be found');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info('The following configuration will be imported in the space ' . $space->domain);
|
||||
|
|
|
|||
|
|
@ -155,6 +155,12 @@ function isRegularExpression(string $string): bool
|
|||
return $isRegularExpression;
|
||||
}
|
||||
|
||||
function replaceHost(string $url, string $host): string
|
||||
{
|
||||
$components = parse_url($url);
|
||||
return str_replace($components['host'], $host, $url);
|
||||
}
|
||||
|
||||
function resolveDomain(Request $request): string
|
||||
{
|
||||
return $request->has('domain')
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class Space extends Model
|
|||
return (int)($this->accounts()->count() / $this->max_accounts * 100);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
public function isFull(): bool
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@
|
|||
"Provisioning of your device": "Déploiement sur votre appareil",
|
||||
"Provisioning tokens": "Jetons de déploiement",
|
||||
"Provisioning": "Déploiement",
|
||||
"Provisioning wizard URL": "URL de l'assistant de déploiement",
|
||||
"Public registration": "Inscription publiques",
|
||||
"QR Code scanning": "Scan de QR Code",
|
||||
"Realm": "Royaume",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<header>
|
||||
<h1><i class="ph ph-users"></i> {{ __('Users') }}</h1>
|
||||
@if ($space)
|
||||
<p>{{ $accounts->count()}} / @if ($space->max_accounts > 0){{ $space->max_accounts }} @else <i class="ph ph-infinity</i>@endif"></p>
|
||||
<p>{{ $accounts->count()}} / @if ($space->max_accounts > 0){{ $space->max_accounts }} @else <i class="ph ph-infinity"></i>@endif</p>
|
||||
@endif
|
||||
<a class="btn secondary oppose" href="{{ route('admin.account.import.create') }}">
|
||||
<i class="ph ph-upload-simple"></i>
|
||||
|
|
|
|||
|
|
@ -111,16 +111,20 @@
|
|||
|
||||
@if ($account->provisioning_token)
|
||||
<div>
|
||||
<img style="max-width: 15rem;" src="{{ route('provisioning.qrcode', $account->provisioning_token) }}">
|
||||
<img style="max-width: 15rem;" src="{{ $account->provisioning_qrcode_url }}">
|
||||
</div>
|
||||
|
||||
<form class="inline">
|
||||
<div>
|
||||
<input type="text" style="min-width: 40rem;" readonly
|
||||
value="{{ route('provisioning.provision', $account->provisioning_token) }}">
|
||||
value="{{ $account->provisioning_url }}">
|
||||
<small>{{ __('The link can only be visited once') }}</small>
|
||||
</div>
|
||||
</form>
|
||||
<p>
|
||||
<i class="ph ph-app-window"></i>
|
||||
<a target="_blank" href="{{ $account->provisioning_wizard_url }}">{{ __('Provisioning wizard URL') }}</a>
|
||||
</p>
|
||||
@else
|
||||
<a class="btn btn-light" href="{{ route('admin.account.provision', $account->id) }}">{{ __('Create') }}</a>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
To connect your account to the application, click on the following link:
|
||||
|
||||
[{{__('Login to my account')}}]({{ route('provisioning.wizard', ['provisioning_token' => $account->provisioning_token]) }})
|
||||
[{{__('Login to my account')}}]({{ $account->provisioning_wizard_url }})
|
||||
|
||||
You can also configure your device by scanning the QR code with the mobile app, or by pasting the link below into the desktop application.
|
||||
|
||||
 }})
|
||||

|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue