Laravel 5/AngularJS custom authentication best practice -


i'm working on application using laravel 5.3 end , angularjs front end. authentication, user's information needs matched against external api. so, i've been using custom version of laravel's built-in authentication, i.e.,

  1. user enters information
  2. angularjs front-end sends laravel back-end
  3. laravel uses auth::login check against external api
  4. either tell user credentials wrong or move them home page

my question is, point forward, bad practice continue using laravel's built-in auth middleware functionality see if user authenticated when move around application?

everything i'm reading seems discuss using token based authentication (mostly jwt), , while method works, i'm new angularjs , ensure i'm doing follows best practice.

thank you!

as far best practices go there lot of different ways go it. use laravel's built in authentication you'd have make sure session id keeps getting sent every request or auth::user null.

when comes api's dont want have session data though, main reason people use tokens jwt or oauth because they're stateless (for part). if use jwt tokens add middelware this:

if (jwtauth::gettoken()) {         jwtauth::parsetoken()->authenticate();     } 

when laravel's authentication methods work expected. in combination jwt.auth middleware comes package. hope clears things little :)


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -