fix bug login & delete

This commit is contained in:
Jagad R R
2025-01-10 17:10:45 +07:00
parent 3ffdb11d3a
commit 7aaa9d5370
3 changed files with 94 additions and 7 deletions
@@ -49,16 +49,16 @@ class LoginController extends Controller
// Check the current guard and redirect accordingly
if (Auth::guard('admin')->check()) {
// Redirect admins to their dashboard
return route('admin.dashboard');
return '/';
}
if (Auth::guard('web')->check()) {
// Redirect regular users to their home or default page
return route('trx_order_elevation.index');
return '/';
}
// Default redirection if no condition matches
return '/admin/login';
return '/login';
}
/**
@@ -104,11 +104,14 @@ class LoginController extends Controller
AuditTrailHelper::AuthAttempt('Login', 'User (' . $request->email . ') Logged in to the System');
return redirect($redirectTo);
} else {
// Log activity
AuditTrailHelper::AuthAttempt('Login', 'Failed login attempt for User (' . $request->email . ')');
// Login failed
session()->flash('error', 'Invalid email or password.');
return back();
}
// Login failed
session()->flash('error', 'Invalid email or password.');
return back();
}
/**
@@ -596,6 +596,7 @@ class FormUpCountryController extends Controller
public function destroy($id)
{
$this->checkAuthorization(auth()->user(), ['forms.country.delete']);
$role = auth()->user()->getRoleNames()[0];
$form = FormUpCountry::findOrfail($id);
if($form->status != 'On Progress' && $role == 'Medical Representatif') {