1

Laravel's auth class requires a database in order for it to be used right?

Does that consider database coming from the server having their own authentication process ? Cause I want to use Laravel's Auth class methods where I can distinguish if the user is logged in or not so that I can prevent them(who have logged out) from clicking the back button.

8
  • Laravel assumes you have a table named "users" in your database. Commented Sep 18, 2013 at 3:52
  • Yes, I know that much, but can I still use it even though i didn't create any database with direct connection to my project? like for example I am accessing a database from a server Commented Sep 18, 2013 at 3:57
  • Well, as long as you have a database connection (local or remote) set up with Laravel and it has a table users it should technically work. Commented Sep 18, 2013 at 3:59
  • even though I don't use Laravel's own logging in method Auth::attempt() will it still work when I use Auth::check()? Commented Sep 18, 2013 at 4:06
  • Oh, that I don't know. Have you tried? What happened? Commented Sep 18, 2013 at 4:07

1 Answer 1

1

Laravel 4 by default support two authentication driver, 'Eloquent' and 'Database', refer to the file you have in your app\config\auth.php, this is set to Eloquent by default.

The Eloquent ORM itself by default tied to a table in your database, though I have seen it creating tables by itself when no tables are found (maybe someone else can clarify this).

If you are not using the Auth::attempt() then it is of best practice to call the Auth::login() or Auth::loginUsingId() in your application. However this depends on how far you want to use your own authentication method (or how much you want to use the bundled authentication, for that matter).

Sign up to request clarification or add additional context in comments.

7 Comments

I don't want to use the Auth::login() because the server does that function. I only want to the Auth::check() to check if the user is still log in instead of using sessions for the back button. But it seems that Laravel's Auth class doesn't recognize the authetication that my server sends me that's why Auth::check() doesn't work, is there any other way to tell the Auth class that my user is logged in without using Auth class' own login method ??
Is your server use their own table structure for storing User information? And also do you have User Eloquent model?
Yes. No, i don't manage the database, I just send the information to the server. I've been thinking of modifying the Illuminate\Auth\Guard.php since this is where the functions user(), check() of Auth class can be found. So I think instead of placing my curl functions in the controller I'll place them in Illuminate\Auth\Guard.php then it will be the one to catch whatever the server's returning.. ?
Yeah do give that a try. Or, start as a filter. Write a filter that filters every route with a curl call to your server (assuming that is how your authentication mechanism work?)
will it be able to handle if the user clicks the back button? if I'm not mistaken I think the headers are set to no-cached by default so the page refreshes but the user is still logged in even though the server returns true when I log out of my page(if this makes any sense)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.