Closed espositodaniele closed 7 years ago
Are you only intending to provide an alert to show someone that they are logged in or will there be other alerts?
Actually, I have other alerts, but they are fired when someone on that page will add some resource, for example: adding a post or editing. I'm facing this problem because I want to fire a flash a message from javascript in a blade template and I don't have any event running in javascript at the moment the users log in. I'm just getting in the admin area from login controller.
Thanks
You could run a check on /api/user and see if a user model is returned
So are you saying that I should make an ajax call to API/user to see if someone is logged in? Uhmm I don't really know it can be an elegant way to solve it... but can be an option.
Thanks
Is the login process being handled by Ajax?
No is not. It is the simple process of Laravel "auth" that provides to use in a really easy way to start. I know If I do it with ajax I can call the flash method on the success request, but is not what I'm trying to achieve.
You could probably do something like this:
<script>
const loggedIn = json_encode(Auth::check());
</script>
And then on page load, I should check if the logged in is set right? If so, on every page load of the dashboard I wil get the message.
Are you using Vue for a SPA?
Nope. As I said before I'm just using the laravel auth. I'm figuring out that is actually not possible.
Yeah, there isn't really a clean/elegant way to handle this that I can think of.
Hello,
I'm trying to use it with Laravel Framework and all I want to do is to flash a message after the user logged in. I can't figure out how to call it from PHP if a session is set. I have tried to call it between the script tag if a session is set and I don't think is best practices to follow.
Thanks