Get laravel current user on external php website

115 views Asked by At

I have created an application with Laravel 7 that contains users that can log in. In parallel, I create a showcase site for the application (another domain) and essentially html/css. I would like on this showcase site to propose login and registration buttons if there is no user connected to the laravel.Otherwise I would just like to propose a "Dashboard" button if a user is connected to the Laravel application.

How to do that? I confess that I'm a bit lost. Thanks for your help.

1

There are 1 answers

1
Thanasis Balatsoykas On

You need to create an API on the laravel app which will be used by the "showcase site".

To login and authorize themselves you can use JWT

to keep user data and use it on the showcase site you can either save them in

  • localstorage (just be careful not to save any sensitive data there as people can take that information in case of XSS vulnerable)
  • indexdb
  • cookies

None of these methods are safe. They can be exploited using XSS so i advice on using JWT to secure sensitive data.