Refactore Profile to Settings & Setting to Options

This commit is contained in:
Bubka 2020-03-09 20:24:25 +01:00
parent 98c02a48dc
commit 80d9433774
18 changed files with 40 additions and 36 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace App\Http\Controllers\Profile;
namespace App\Http\Controllers\Settings;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

View File

@ -1,12 +1,12 @@
<?php
namespace App\Http\Controllers\Profile;
namespace App\Http\Controllers\Settings;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
class SettingController extends Controller
class OptionController extends Controller
{

View File

@ -1,6 +1,6 @@
<?php
namespace App\Http\Controllers\Profile;
namespace App\Http\Controllers\Settings;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

View File

@ -8,7 +8,7 @@
</div>
</div>
<div class="content has-text-centered">
<router-link :to="{ name: 'profile' }" class="has-text-grey">{{ $t('commons.profile') }}</router-link> - <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
<router-link :to="{ name: 'settings' }" class="has-text-grey">{{ $t('settings.settings') }}</router-link> - <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
</div>
</footer>
</template>

View File

@ -79,6 +79,7 @@ export default {
"settings": "Settings",
"account": "Account",
"password": "Password",
"options": "Options",
"confirm": [],
"forms": {
"edit_settings": "Edit settings",
@ -283,7 +284,7 @@ export default {
"already_register": "Déjà enregistré ?",
"password_do_not_match": "Le mot de passe ne correspond pas",
"forgot_your_password": "Mot de passe oublié ?",
"request_password_reset": "Réinitialiser le",
"request_password_reset": "Réinitialiser le mot de passe",
"reset_password": "Mot de passe oublié",
"new_password": "Nouveau mot de passe",
"current_password": {
@ -341,6 +342,7 @@ export default {
"settings": "Réglages",
"account": "Compte",
"password": "Mot de passe",
"options": "Options",
"confirm": [],
"forms": {
"edit_settings": "Modifier les réglages",

View File

@ -10,7 +10,7 @@ import Login from './views/auth/Login'
import Register from './views/auth/Register'
import PasswordRequest from './views/auth/password/Request'
import PasswordReset from './views/auth/password/Reset'
import Profile from './views/profile/Index'
import Settings from './views/Settings/Index'
import Errors from './views/Error'
const router = new Router({
@ -19,7 +19,7 @@ const router = new Router({
{ path: '/', name: 'accounts', component: Accounts, props: true },
{ path: '/login', name: 'login',component: Login },
{ path: '/register', name: 'register',component: Register },
{ path: '/profile', name: 'profile',component: Profile },
{ path: '/settings', name: 'settings',component: Settings },
{ path: '/create', name: 'create',component: Create },
{ path: '/edit/:twofaccountId', name: 'edit',component: Edit },

View File

@ -27,7 +27,7 @@
},
async mounted() {
const { data } = await this.form.get('/api/profile/account')
const { data } = await this.form.get('/api/settings/account')
this.form.fill(data)
},
@ -39,7 +39,7 @@
this.fail = ''
this.success = ''
this.form.patch('/api/profile/account', {returnError: true})
this.form.patch('/api/settings/account', {returnError: true})
.then(response => {
this.success = response.data.message

View File

@ -11,7 +11,7 @@
</div>
</div>
</div>
<settings v-if="activeTab === $t('settings.settings')"></settings>
<options v-if="activeTab === $t('settings.options')"></options>
<account v-if="activeTab === $t('settings.account')"></account>
<password v-if="activeTab === $t('settings.password')"></password>
<vue-footer :showButtons="true">
@ -25,7 +25,7 @@
<script>
import Settings from './Settings'
import Options from './Options'
import Account from './Account'
import Password from './Password'
@ -34,7 +34,7 @@
return {
tabs: [
{
'name' : this.$t('settings.settings'),
'name' : this.$t('settings.options'),
'isActive': true
},
{
@ -46,12 +46,12 @@
'isActive': false
},
],
activeTab: this.$t('settings.settings')
activeTab: this.$t('settings.options')
}
},
components: {
Settings,
Options,
Account,
Password
},

View File

@ -34,7 +34,7 @@
this.fail = ''
this.success = ''
this.form.post('/api/profile/settings', {returnError: true})
this.form.post('/api/settings/options', {returnError: true})
.then(response => {
this.success = response.data.message

View File

@ -33,7 +33,7 @@
this.fail = ''
this.success = ''
this.form.patch('/api/profile/password', {returnError: true})
this.form.patch('/api/settings/password', {returnError: true})
.then(response => {
this.success = response.data.message

View File

@ -16,6 +16,7 @@
'settings' => 'Settings',
'account' => 'Account',
'password' => 'Password',
'options' => 'Options',
'confirm' => [
],

View File

@ -33,7 +33,7 @@
'already_register' => 'Déjà enregistré ?',
'password_do_not_match' => 'Le mot de passe ne correspond pas',
'forgot_your_password' => 'Mot de passe oublié ?',
'request_password_reset' => 'Réinitialiser le',
'request_password_reset' => 'Réinitialiser le mot de passe',
'reset_password' => 'Mot de passe oublié',
'new_password' => 'Nouveau mot de passe',
'current_password' => [

View File

@ -16,6 +16,7 @@
'settings' => 'Réglages',
'account' => 'Compte',
'password' => 'Mot de passe',
'options' => 'Options',
'confirm' => [
],

View File

@ -28,11 +28,11 @@
Route::post('logout', 'Auth\LoginController@logout');
Route::get('profile/account', 'Profile\AccountController@show');
Route::patch('profile/account', 'Profile\AccountController@update');
Route::patch('profile/password', 'Profile\PasswordController@update');
Route::get('profile/settings', 'Profile\SettingController@index');
Route::post('profile/settings', 'Profile\SettingController@store');
Route::get('settings/account', 'Settings\AccountController@show');
Route::patch('settings/account', 'Settings\AccountController@update');
Route::patch('settings/password', 'Settings\PasswordController@update');
Route::get('settings/options', 'Settings\OptionController@index');
Route::post('settings/options', 'Settings\OptionController@store');
Route::delete('twofaccounts/batch', 'TwoFAccountController@batchDestroy');
Route::apiResource('twofaccounts', 'TwoFAccountController');

View File

@ -35,7 +35,7 @@ public function setUp(): void
*/
public function test_HTTP_UNAUTHORIZED()
{
$response = $this->json('GET', '/api/profile/settings')
$response = $this->json('GET', '/api/settings/options')
->assertStatus(401)
->assertJson([
'message' => 'Unauthorized'
@ -78,7 +78,7 @@ public function test_HTTP_NOT_FOUND()
public function test_HTTP_METHOD_NOT_ALLOWED()
{
$response = $this->actingAs($this->user, 'api')
->json('PATCH', '/api/profile/settings')
->json('PATCH', '/api/settings/options')
->assertStatus(405)
->assertJson([
'message' => 'Method Not Allowed'

View File

@ -1,6 +1,6 @@
<?php
namespace Tests\Unit\Profile;
namespace Tests\Unit\Settings;
use App\User;
use Tests\TestCase;
@ -32,7 +32,7 @@ public function testGetUserDetails()
$user = User::find(1);
$response = $this->actingAs($user, 'api')
->json('GET', '/api/profile/account')
->json('GET', '/api/settings/account')
->assertStatus(200)
->assertJsonStructure(['name', 'email']);
}
@ -48,7 +48,7 @@ public function testUserUpdateWithWrongCurrentPassword()
$user = User::find(1);
$response = $this->actingAs($user, 'api')
->json('PATCH', '/api/profile/account', [
->json('PATCH', '/api/settings/account', [
'name' => 'userUpdated',
'email' => 'userUpdated@example.org',
'password' => 'wrongPassword',
@ -69,7 +69,7 @@ public function testUserUpdate()
$user = User::find(1);
$response = $this->actingAs($user, 'api')
->json('PATCH', '/api/profile/account', [
->json('PATCH', '/api/settings/account', [
'name' => 'userUpdated',
'email' => 'userUpdated@example.org',
'password' => 'password',

View File

@ -1,11 +1,11 @@
<?php
namespace Tests\Unit\Profile;
namespace Tests\Unit\Settings;
use App\User;
use Tests\TestCase;
class SettingTest extends TestCase
class OptionTest extends TestCase
{
/** @var \App\User */
protected $user;
@ -30,7 +30,7 @@ public function setUp(): void
public function testSettingsStorage()
{
$response = $this->actingAs($this->user, 'api')
->json('POST', '/api/profile/settings', [
->json('POST', '/api/settings/options', [
'setting_1' => 'value_1',
'setting_2' => 'value_2',
])
@ -56,7 +56,7 @@ public function testSettingsIndexListing()
option(['setting_2' => 'value_2']);
$response = $this->actingAs($this->user, 'api')
->json('GET', '/api/profile/settings')
->json('GET', '/api/settings/options')
->assertStatus(200)
->assertJson([
'settings' => [

View File

@ -1,6 +1,6 @@
<?php
namespace Tests\Unit\Profile;
namespace Tests\Unit\Settings;
use App\User;
use Tests\TestCase;
@ -31,7 +31,7 @@ public function setUp(): void
public function testPasswordUpdateWithWrongCurrentPassword()
{
$response = $this->actingAs($this->user, 'api')
->json('PATCH', '/api/profile/password', [
->json('PATCH', '/api/settings/password', [
'currentPassword' => 'wrongPassword',
'password' => 'passwordUpdated',
'password_confirmation' => 'passwordUpdated',
@ -50,7 +50,7 @@ public function testPasswordUpdateWithWrongCurrentPassword()
public function testPasswordUpdate()
{
$response = $this->actingAs($this->user, 'api')
->json('PATCH', '/api/profile/password', [
->json('PATCH', '/api/settings/password', [
'currentPassword' => 'password',
'password' => 'passwordUpdated',
'password_confirmation' => 'passwordUpdated',