Laravel - Help with Authentication

Asked

Viewed 550 times

1

I’m using Laravel 5.3 and I’m having a headache with Authentication. I’m using make:auth. So far it’s simple, but let’s look at the scenario below.

In my project, when I log in I send the email and password to the API(Node) that returns a token if the user exists. So far this is ok. With the token and user data returned I would like to use Laravel make:Auth to log in. To continue using Auth::user(), Auth::check() and etc and maintain the structure that Laravel already provides me.

I did some research and didn’t find much on this subject.

Does anyone know if there is a way? If so, can you give me an example? Or maybe I can create a Custom Authentication that can continue using Auth::user(), Auth::check() and so on? If anyone knows accept examples too. :)

UPDATE

The Project:

I’m using the Heroku platform (https://www.heroku.com/) where is my Web Service (Node) and Database (Mongo), and I am using Laravel for my Website.

What I want to do:

When I log in, my Apicontroller sends with Curl a request to the Webservice by passing the user’s email and password. The Webservice will do the check, if there is no user it returns null and if there is a user it returns me a token with the user’s data. What to do with the token and user data? As far as I know, I need to save in a Session. If I use Session to save the data I can’t for example return the user using Auth::user() or if I want to check I can’t use Auth:check().

Hence my question. Is there any way to save the token and user data and continue using Auth::user(), Auth::check() and etc?

These two links below help in understanding my question. I tried to follow a step by step to create a Custom Auth, but I got lost in the sequence and could not get in touch with who had the same doubt as me. :(

Link 1: https://stackoverflow.com/questions/41154660/laravel-auth-external-data-for-login-and-register?rq=1

Link 2: https://stackoverflow.com/questions/38104647/laravel-authentication-via-external-api

  • Node + Laravel Framework ? is that it !!!!!!!!!! ???

  • Web Service in Node and the Web Site in Laravel. It’s a bad idea?

  • no, is that your question does not have a specific focus, is a little confused!

  • Beauty! I will edit and try to leave a little better understanding ;)

  • Face only clarifies me one thing, in its application in Aravel will consume all the information of its Webservices in Node? or your application will also have a database?

  • @Kayobruno Everything will be consumed from the Webservice!

  • @gViegas You will have to create a custom authenication driver, with this you will be able to use the Auth methods. In the Laravel documentation there are examples of how you can do it.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.