authentication - What is the correct way to use Laravel basic auth with angularjs? -
here approach follow.
i secure routes api this:
route::group(array('prefix' => '/api/v1'), function () { route::get('dashboard', array('before' => 'basic.once', function () { return 'dashboard'; })); });
i planning use basic auth on ssl connection.
i have send username , password every request.
i understand need store user details on client side (angular/browser) user logs in once , allowed access protected routes until session valid.
what don't understand user information store @ client end , how?
the api used building mobile apps in future.
what simplest thing can achieve this?
the simplest way when user register (or create user), add field not standard credentials (username, password), field can token you'll generate when create user, after when user logs in send him unique token, , @ client side (angularjs) can store token example in session storage, , after need send token every api call. simplify back-end can make filter test token , log in user. important if want use application on mobile devices aren't cookies, log in users every call.
Comments
Post a Comment