Ad

Auth User With A Key

- 1 answer

I would like to make an auth page to my website with only a Key field.

enter image description here

Example : I give an Key like 'A5DP7123OAC' to my customer for the login.

And if the code is correct he can access to his panel. Actually I just create a Cookie :

withCookie(cookie()->forever('access', 'true'));

But it's not a good way I think.

Do you have solution to Auth an user only with a Key ?

Thank's

Ad

Answer

You could pass your key to the session and then check to see if the key the user provides matches the key in the session. If so you can log the user in manually using one of the methods found here: https://laravel.com/docs/5.2/authentication#other-authentication-methods

If you don't want to use the session, you could also create a DB table and store your keys there optionally giving them expirations so that the keys are only valid for a period of time. You could also make it so that keys are only valid for one IP address. Plenty of options.

Ad
source: stackoverflow.com
Ad