mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix #127 Move the API Key management form to a specific page
This commit is contained in:
parent
e996a9827c
commit
ab6aa88b3c
6 changed files with 83 additions and 33 deletions
|
|
@ -43,14 +43,6 @@ class AccountController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function generateApiKey(Request $request)
|
||||
{
|
||||
$account = $request->user();
|
||||
$account->generateApiKey();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function store(CreateAccountRequest $request)
|
||||
{
|
||||
$account = (new AccountService(api: false))->store($request);
|
||||
|
|
|
|||
41
flexiapi/app/Http/Controllers/Account/ApiKeyController.php
Normal file
41
flexiapi/app/Http/Controllers/Account/ApiKeyController.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2020 Belledonne Communications SARL, All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApiKeyController extends Controller
|
||||
{
|
||||
public function show(Request $request)
|
||||
{
|
||||
return view('account.api_key', [
|
||||
'account' => $request->user()
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$account = $request->user();
|
||||
$account->generateApiKey();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
26
flexiapi/resources/views/account/api_key.blade.php
Normal file
26
flexiapi/resources/views/account/api_key.blade.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
@extends('layouts.main', ['grid' => true])
|
||||
|
||||
@section('content')
|
||||
<header>
|
||||
<h1><i class="material-icons-outlined">dashboard</i> Dashboard</h1>
|
||||
</header>
|
||||
|
||||
<div class="large">
|
||||
<h2><i class="material-icons-outlined">key</i>API Key</h2>
|
||||
|
||||
<p>You can generate an API key and use it to request the different API endpoints, <a href="{{ route('api') }}">check
|
||||
the related API documentation</a> to know how to use that key.</p>
|
||||
|
||||
<form method="POST" action="{{ route('account.api_key.update') }}" accept-charset="UTF-8">
|
||||
@csrf
|
||||
<div>
|
||||
<input readonly placeholder="No key yet, press Generate"
|
||||
@if ($account->apiKey) value="{{ $account->apiKey->key }}" @endif>
|
||||
<label>Key</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">Generate</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
</p>
|
||||
<p>
|
||||
<i class="material-icons-outlined">lock</i>
|
||||
<a href="{{ route('account.password') }}">
|
||||
<a href="{{ route('account.password.show') }}">
|
||||
@if ($account->passwords()->count() > 0)
|
||||
Change my password
|
||||
@else
|
||||
|
|
@ -37,6 +37,13 @@
|
|||
</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<i class="material-icons-outlined">key</i>
|
||||
<a href="{{ route('account.api_key.show') }}">
|
||||
API Key Management
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<i class="material-icons-outlined">delete</i>
|
||||
<a href="{{ route('account.delete') }}">Delete my account</a>
|
||||
|
|
@ -75,25 +82,5 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div class="large">
|
||||
<h2><i class="material-icons-outlined">key</i>API Key</h2>
|
||||
|
||||
<p>You can generate an API key and use it to request the different API endpoints, <a href="{{ route('api') }}">check
|
||||
the related API documentation</a> to know how to use that key.</p>
|
||||
|
||||
<form method="POST" action="{{ route('account.api_key.generate') }}" accept-charset="UTF-8">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<input readonly placeholder="No key yet, press Generate"
|
||||
@if ($account->apiKey) value="{{ $account->apiKey->key }}" @endif>
|
||||
<label>Key</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">Generate</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@include('parts.account_variables', ['account' => $account])
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ You can @if (config('app.web_panel')) [change your email address]({{ route('acco
|
|||
|
||||
## Change your password
|
||||
|
||||
Your password can also be changed from the @if (config('app.web_panel')) [password change form]({{ route('account.password') }}) @else password change form @endif. You can enable SHA-256 encrypted password when changing it (required for some clients).
|
||||
Your password can also be changed from the @if (config('app.web_panel')) [password change form]({{ route('account.password.show') }}) @else password change form @endif. You can enable SHA-256 encrypted password when changing it (required for some clients).
|
||||
|
||||
## Delete your account
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
use App\Http\Controllers\Account\AccountController;
|
||||
use App\Http\Controllers\Account\ApiKeyController;
|
||||
use App\Http\Controllers\Account\CreationRequestTokenController;
|
||||
use App\Http\Controllers\Account\EmailController;
|
||||
use App\Http\Controllers\Account\PasswordController;
|
||||
|
|
@ -107,8 +108,6 @@ if (config('app.web_panel')) {
|
|||
Route::controller(AccountController::class)->group(function () {
|
||||
Route::get('dashboard', 'panel')->name('account.dashboard');
|
||||
|
||||
Route::post('api_key', 'generateApiKey')->name('account.api_key.generate');
|
||||
|
||||
Route::get('delete', 'delete')->name('account.delete');
|
||||
Route::delete('delete', 'destroy')->name('account.destroy');
|
||||
});
|
||||
|
|
@ -116,10 +115,15 @@ if (config('app.web_panel')) {
|
|||
Route::get('logout', 'Account\AuthenticateController@logout')->name('account.logout');
|
||||
|
||||
Route::prefix('password')->controller(PasswordController::class)->group(function () {
|
||||
Route::get('/', 'show')->name('account.password');
|
||||
Route::get('/', 'show')->name('account.password.show');
|
||||
Route::post('/', 'update')->name('account.password.update');
|
||||
});
|
||||
|
||||
Route::prefix('api_key')->controller(ApiKeyController::class)->group(function () {
|
||||
Route::get('/', 'show')->name('account.api_key.show');
|
||||
Route::post('/', 'update')->name('account.api_key.update');
|
||||
});
|
||||
|
||||
Route::post('auth_tokens', 'Account\AuthTokenController@create')->name('account.auth_tokens.create');
|
||||
|
||||
Route::get('auth_tokens/auth/external/{token}', 'Account\AuthTokenController@authExternal')->name('auth_tokens.auth.external');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue