It seems that the issue you're facing is related to using Inertia.js with Laravel. In Inertia.js, you cannot return a traditional redirect response from your controller. Instead, you should use Inertia's native methods to handle redirection.
Update your authenticateAgency method to return an Inertia response:
use Inertia\Inertia;
public function authenticateAgency(Request $request)
{
if (Auth::guard('agency')->attempt($request->only('email', 'password'))) {
$request->session()->regenerate();
return Inertia::location(route('agencyHome'));
} else {
Auth::logout();
return Inertia::render('YourLoginFormComponent', [
'error' => 'You are not authorized to access this resource',
])->withInput($request->only('email'));
}
}
Replace YourLoginFormComponent with the name of your Vue.js login form component.
In your Vue.js login form component, make sure to handle and display the error message:
<template>
<!-- Your form markup -->
<div v-if="error">{{ error }}</div>
</template>
<script>
export default {
props: {
error: String,
},
// rest of your component code
};
</script>
By using Inertia's native methods, you should be able to handle redirection and display error messages in your Laravel + Inertia.js application.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community