Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kristi11 committed Nov 16, 2024
1 parent b177fe5 commit cd313c6
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 171 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ The following are the known issues that need addressing and i hope that the comm
* Cart items don't get sent from `session id` to `user_id` if the user was logged out when placing the order but after filling out the cart logs in/registers for an account to continue with the order.

* I've to fix the route to redirect to filament login page instead of a default laravel page when user is not logged in.
* There's a bug where `panel_user` role is not assigned to customers in production server. Everything works as intended in local server

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
40 changes: 25 additions & 15 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,33 @@ public function orders(): HasMany
/**
* @throws Exception
*/
// public function canAccessPanel(Panel $panel): bool
// {
// // Check the panel ID to determine access rules
// if ($panel->getId() === 'admin') {
// // Only super admins can access the 'admin' panel
// return $this->hasRole('super_admin');
// } elseif ($panel->getId() === 'team') {
// // Allow access to the 'customer' panel for customers
// return $this->hasRole('team_user');
// } elseif // Check the panel ID to determine access rules
// ($panel->getId() === 'customer') {
// // Allow access to the 'customer' panel for customers
// return $this->hasRole('panel_user');
// } else {
// // Deny access to all other panels
// return false;
// }
// }

public function canAccessPanel(Panel $panel): bool
{
// Check the panel ID to determine access rules
if ($panel->getId() === 'admin') {
// Only super admins can access the 'admin' panel
return $this->hasRole('super_admin');
} elseif ($panel->getId() === 'team') {
// Allow access to the 'customer' panel for customers
return $this->hasRole('team_user');
} elseif // Check the panel ID to determine access rules
($panel->getId() === 'customer') {
// Allow access to the 'customer' panel for customers
return $this->hasRole('panel_user');
} else {
// Deny access to all other panels
return false;
}
return match ($panel->getId()) {
'admin' => $this->hasRole('super_admin'),
'team' => $this->hasRole('team_user'),
// 'customer' => $this->hasRole('panel_user'),
default => true,
};
}

public function canComment(): bool
Expand Down
16 changes: 8 additions & 8 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public function boot(): void
Model::unguard();

Cashier::calculateTaxes();
Fortify::authenticateUsing(function (Request $request) {
$user = User::where('email', $request->email)->first();

if ($user && Hash::check($request->password, $user->password)) {
(new MigrateSessionCart)->migrate(CartFactory::make(), $user?->cart ?: $user->cart()->create());
return $user;
}
});
// Fortify::authenticateUsing(function (Request $request) {
// $user = User::where('email', $request->email)->first();
//
// if ($user && Hash::check($request->password, $user->password)) {
// (new MigrateSessionCart)->migrate(CartFactory::make(), $user?->cart ?: $user->cart()->create());
// return $user;
// }
// });

Gallery::observe(GalleryObserver::class);
Appointment::observe(AppointmentObserver::class);
Expand Down
Loading

0 comments on commit cd313c6

Please sign in to comment.