R
R
Roman2019-04-03 11:56:26
Laravel
Roman, 2019-04-03 11:56:26

How to make authentication exclusively by token (Laravel Passport) in Laravel so that the email and password fields are completely removed from the model?

Hello.
I'm reading the documentation but I don't understand how can I make the token from Laravel Passport the ONLY ID in the system? That is, the user came to the site - the application gives him a
token and says:
- Here is your token - now for me it is you
API to transfer (according to the documentation)
How to do this?
In the documentation examples, the email and password fields are everywhere, and I need authentication to be without them at all.
Thanks in advance for advice or links!
PS Details:
- A person accesses the site using a browser.
- The application looks for the presence of an authenticated session, and if there is no session, it automatically creates a user and immediately logs him in.
- Moreover, the ONLY user identifier is a random token (there is no login, no password, no email).
- The application informs the user of his token.
- And offers to log in under another token if he already has one (from the last time).
What is the best and easiest way to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2019-04-03
@JhaoDa

This is done by writing a custom guard and user provider.
Laravel already has a similar guard for api tokens.
PS During this time, it was possible to study the documentation up and down and not ask such noob questions ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question