Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement change password for refugee and fix it for host and admin as well #176

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ yarn-error.log
/storage/*.index
.DS_Store
composer.phar
mysql-dump
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function saveResetPassword(ResetPasswordRequest $request)
abort(403);
}

$user->password = Hash::make($request->post('newPassword'));
$user->password = Hash::make($request->post('password'));
$user->save();

return redirect()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Host/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function saveResetPassword(ResetPasswordRequest $request)
abort(403);
}

$user->password = Hash::make($request->post('newPassword'));
$user->password = Hash::make($request->post('password'));
$user->save();

return redirect()
Expand Down
38 changes: 38 additions & 0 deletions app/Http/Controllers/Refugee/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
use App\AccommodationPhoto;
use App\FacilityType;
use App\Http\Controllers\Controller;
use App\Http\Requests\ResetPasswordRequest;
use App\User;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\View\View;

class ProfileController extends Controller
Expand All @@ -28,6 +30,42 @@ public function profile(): View
return view('refugee.profile',compact('user'));
}

/**
* @return View
*/
public function resetPassword()
{
/** @var User $user */
$user = Auth::user();

if (empty($user)) {
abort(403);
}

return view('refugee.reset-password')
->with('user', $user);
}

/**
* @param ResetPasswordRequest $request
* @return RedirectResponse
*/
public function saveResetPassword(ResetPasswordRequest $request)
{
$user = Auth::user();

if (empty($user)) {
abort(403);
}

$user->password = Hash::make($request->post('password'));
$user->save();

return redirect()
->route('refugee.profile')
->withSuccess(__('Data successfully saved!'));
}

public function helpRequests(int $page = 1): View
{
/** @var User $user */
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"Select School": "Selectează Școala",
"Profile": "Profil",
"My Profile": "Profilul meu",
"My account": "Contul meu",
"Ask for Information": "Cere informații",
"My Requests": "Solicitările mele",
"Logout": "Ieși din cont",
"Your email address is not verified.": "Adresa dumneavoastră de email nu a fost verificată.",
"Verify Your Email Address": "Verifică adresa de email",
"Before proceeding, please check your email for a verification link.": "Pentru a merge mai departe, vă rugăm verificați adresa de email pentru un link de validare.",
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<span class="list-group-item list-group-header">
{{ Auth::user()->name }}
</span>
<a href="{{ route('admin.profile') }}" class="list-group-item list-group-item-action ">
<a href="{{ route('refugee.profile') }}" class="list-group-item list-group-item-action ">
<i class="fa fa-user mr-3"></i>{{__('My account')}}
</a>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/refugee/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<h6 class="font-weight-600 text-white mb-0">
{{ __("Account information") }}
</h6>
<a class="btn btn-secondary btn-sm px-4" href="{{ route('host.reset-password') }}">{{ __("Reset password") }}</a>
<a class="btn btn-secondary btn-sm px-4" href="{{ route('refugee.reset-password') }}">{{ __("Reset password") }}</a>
</div>
<div class="card-body pt-4">
<div class="kv d-flex">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/refugee/reset-password.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@section('content')
<section class="mb-5">
<h6 class="page-title mb-3 font-weight-600">{{ __("Reset password") }}</h6>
<a href="{{ route('host.profile') }}" class="btn btn-sm btn-outline-primary mr-3">{{ __("Back") }}</a>
<a href="{{ route('refugee.profile') }}" class="btn btn-sm btn-outline-primary mr-3">{{ __("Back") }}</a>
</section>

<div class="card shadow">
Expand All @@ -13,7 +13,7 @@
</h6>
</div>
<div class="card-body pt-4">
<form action="{{ @route('host.save-reset-password') }}" method="post">
<form action="{{ @route('refugee.save-reset-password') }}" method="post">
@csrf
<div class="row">
<div class="col-sm-6">
Expand Down
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
->group(function () {
Route::get('/', 'Refugee\ProfileController@home')->name('refugee.home');
Route::get('/profile', 'Refugee\ProfileController@profile')->name('refugee.profile');
Route::get('/profile/reset-password', 'Refugee\ProfileController@resetPassword')->name('refugee.reset-password');
Route::post('/profile/reset-password', 'Refugee\ProfileController@saveResetPassword')->name('refugee.save-reset-password');
Route::get('/help-requests', 'Refugee\ProfileController@helpRequests')->name('refugee.help.requests');
Route::get('/information', 'Refugee\ProfileController@information')->name('refugee.information');
Route::get('/accommodation/{accommodation}/view', 'Refugee\ProfileController@viewAccommodation')->name('refugee.view-accommodation');
Expand Down