From 90924668308f82a49a9ad07fff9d6bf74a3f6111 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 11 Nov 2018 23:11:19 +0800 Subject: [PATCH] Move Change Passoword to Auth namespace --- .../Controllers/Auth/ChangePasswordController.php | 38 ++++++++++++++++++++++ app/Http/Controllers/ChangePasswordController.php | 25 -------------- routes/web.php | 6 ++-- tests/Feature/ChangePasswordTest.php | 12 +++---- 4 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 app/Http/Controllers/Auth/ChangePasswordController.php delete mode 100644 app/Http/Controllers/ChangePasswordController.php diff --git a/app/Http/Controllers/Auth/ChangePasswordController.php b/app/Http/Controllers/Auth/ChangePasswordController.php new file mode 100644 index 0000000..b6ccb70 --- /dev/null +++ b/app/Http/Controllers/Auth/ChangePasswordController.php @@ -0,0 +1,38 @@ +password = bcrypt($request->new_password); + $updateResponse = array('error' => __('auth.change_password_error')); + + if ($user->save()) { + $updateResponse = array('success' => __('auth.change_password_success')); + } + + return redirect()->back()->with($updateResponse); + } +} diff --git a/app/Http/Controllers/ChangePasswordController.php b/app/Http/Controllers/ChangePasswordController.php deleted file mode 100644 index 245883c..0000000 --- a/app/Http/Controllers/ChangePasswordController.php +++ /dev/null @@ -1,25 +0,0 @@ -password = bcrypt($request->new_password); - - if ($user->save()) $updateResponse = array('success' => trans('auth.change_password_success')); - else $updateResponse = array('error' => trans('auth.change_password_error')); - - return redirect()->back()->with($updateResponse); - } -} diff --git a/routes/web.php b/routes/web.php index 4265ef6..2b0eec0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,6 +15,9 @@ Route::get('/', 'UsersController@search'); Auth::routes(); +Route::get('profile/update-password', 'Auth\ChangePasswordController@show')->middleware('auth')->name('profile.change-password.form'); +Route::post('profile/update-password', 'Auth\ChangePasswordController@update')->middleware('auth')->name('profile.change-password.update'); + Route::get('home', 'HomeController@index')->name('home'); Route::get('profile', 'HomeController@index')->name('profile'); Route::post('family-actions/{user}/set-father', 'FamilyActionsController@setFather')->name('family-actions.set-father'); @@ -24,9 +27,6 @@ Route::post('family-actions/{user}/add-wife', 'FamilyActionsController@addWife') Route::post('family-actions/{user}/add-husband', 'FamilyActionsController@addHusband')->name('family-actions.add-husband'); Route::post('family-actions/{user}/set-parent', 'FamilyActionsController@setParent')->name('family-actions.set-parent'); -Route::get('profile/update-password', 'ChangePasswordController@show')->middleware('auth')->name('profile.change-password.form'); -Route::post('profile/update-password', 'ChangePasswordController@update')->middleware('auth')->name('profile.change-password.update'); - Route::get('profile-search', 'UsersController@search')->name('users.search'); Route::get('users/{user}', 'UsersController@show')->name('users.show'); Route::get('users/{user}/edit', 'UsersController@edit')->name('users.edit'); diff --git a/tests/Feature/ChangePasswordTest.php b/tests/Feature/ChangePasswordTest.php index 546003a..2e03cb6 100644 --- a/tests/Feature/ChangePasswordTest.php +++ b/tests/Feature/ChangePasswordTest.php @@ -15,15 +15,15 @@ class ChangePasswordTest extends TestCase $user = $this->loginAsUser(['password' => bcrypt('secret')]); $this->visit(route('home')); - $this->click(trans('auth.change_password')); + $this->click(__('auth.change_password')); - $this->submitForm(trans('auth.change_password'), [ + $this->submitForm(__('auth.change_password'), [ 'old_password' => 'secret', 'new_password' => 'rahasia', 'new_password_confirmation' => 'rahasia', ]); - $this->seeText(trans('auth.change_password_success')); + $this->seeText(__('auth.change_password_success')); $this->assertTrue( app('hash')->check('rahasia', $user->password), @@ -37,15 +37,15 @@ class ChangePasswordTest extends TestCase $user = $this->loginAsUser(['password' => bcrypt('secret')]); $this->visit(route('home')); - $this->click(trans('auth.change_password')); + $this->click(__('auth.change_password')); - $this->submitForm(trans('auth.change_password'), [ + $this->submitForm(__('auth.change_password'), [ 'old_password' => 'member1', 'new_password' => 'rahasia', 'new_password_confirmation' => 'rahasia', ]); - $this->seeText(trans('passwords.old_password')); + $this->seeText(__('passwords.old_password')); $this->assertTrue( app('hash')->check('secret', $user->password),