Skip to content

Commit

Permalink
Merge pull request #407 from Danjosh0211/main
Browse files Browse the repository at this point in the history
fix: Profile Encoding Id Issues
  • Loading branch information
nasirkhan authored Apr 14, 2023
2 parents c7fdd73 + 12ea079 commit 770101d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions app/Http/Controllers/Frontend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function profileEdit($id)
}

if ($id != auth()->user()->id) {
return redirect()->route('frontend.users.profile', $id);
return redirect()->route('frontend.users.profile', encode_id($id));
}

$$module_name_singular = $module_model::findOrFail($id);
Expand All @@ -160,16 +160,16 @@ public function profileEdit($id)
*/
public function profileUpdate(Request $request, $id)
{
$id = decode_id($id);
$module_title = $this->module_title;
$module_name = $this->module_name;
$module_path = $this->module_path;
$module_icon = $this->module_icon;
$module_model = $this->module_model;
$module_name_singular = Str::singular($module_name);
$module_action = 'Profile Update';

if ($id != auth()->user()->id) {
return redirect()->route('frontend.users.profile', $id);
return redirect()->route('frontend.users.profile', encode_id($id));
}

$this->validate($request, [
Expand Down Expand Up @@ -210,7 +210,7 @@ public function profileUpdate(Request $request, $id)

event(new UserProfileUpdated($user_profile));

return redirect()->route('frontend.users.profile', $$module_name_singular->id)->with('flash_success', 'Update successful!');
return redirect()->route('frontend.users.profile', encode_id($$module_name_singular->id))->with('flash_success', 'Update successful!');
}

/**
Expand All @@ -221,6 +221,8 @@ public function profileUpdate(Request $request, $id)
*/
public function changePassword($id)
{
$id = decode_id($id);

$module_title = $this->module_title;
$module_name = $this->module_name;
$module_path = $this->module_path;
Expand All @@ -232,7 +234,7 @@ public function changePassword($id)
$body_class = 'profile-page';

if ($id != auth()->user()->id) {
return redirect()->route('frontend.users.profile', $id);
return redirect()->route('frontend.users.profile', encode_id($id));
}

$id = auth()->user()->id;
Expand Down Expand Up @@ -290,7 +292,7 @@ public function edit($id)
$module_action = 'Edit';

if ($id != auth()->user()->id) {
return redirect()->route('frontend.users.profile', $id);
return redirect()->route('frontend.users.profile', encode_id($id));
}

$roles = Role::get();
Expand Down Expand Up @@ -318,7 +320,7 @@ public function update(Request $request, $id)
$module_name_singular = Str::singular($this->module_name);

if ($id != auth()->user()->id) {
return redirect()->route('frontend.users.profile', $id);
return redirect()->route('frontend.users.profile', encode_id($id));
}

$$module_name_singular = User::findOrFail($id);
Expand Down Expand Up @@ -393,6 +395,8 @@ public function userProviderDestroy(Request $request)
*/
public function emailConfirmationResend($id)
{
$id = decode_id($id);

if ($id != auth()->user()->id) {
if (auth()->user()->hasAnyRole(['administrator', 'super admin'])) {
Log::info(auth()->user()->name.' ('.auth()->user()->id.') - User Requested for Email Verification.');
Expand Down
4 changes: 2 additions & 2 deletions resources/views/frontend/users/changePassword.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@auth
@if(auth()->user()->id == $$module_name_singular->id)
<small>
<a href="{{ route('frontend.users.profileEdit', $$module_name_singular->id) }}" class="btn btn-primary btn-sm">Show</a>
<a href="{{ route('frontend.users.profileEdit', encode_id($$module_name_singular->id)) }}" class="btn btn-primary btn-sm">Show</a>
</small>
@endif
@endauth
Expand All @@ -23,7 +23,7 @@
</p>
@if ($$module_name_singular->email_verified_at == null)
<p class="lead">
<a href="{{route('frontend.users.emailConfirmationResend', $$module_name_singular->id)}}">Confirm Email</a>
<a href="{{route('frontend.users.emailConfirmationResend', encode_id($$module_name_singular->id))}}">Confirm Email</a>
</p>
@endif

Expand Down

0 comments on commit 770101d

Please sign in to comment.