Authenticate to angularJS with $scope?

The doubt has arisen because my login is something different since when validating a user in the WS, this one has to return data in JSON, since with that data I consult another WS to receive new data and show them in the view

I'm trying NG-cookies, i.e. if the authentication passes I save the data in a cookie:

cookieStore.put('nombreCookie',response);

Thing that when refreshing the page is not lost the data since by mid session the data is save to a variable called logindata. which is the one I use to make the requests but as it is only loaded at session start they are not saved and causes that to Refresh Page no longer extstan data...

I want to know how I can send as a parameter the data stored in the cookie...

Greetings.

 0
Author: Hernan HumaƱa, 2016-09-20

1 answers

If your application is going to consume two or more WS I would recommend that you use JWT token authentication.

If you use cookies you must be careful when creating them because you will have problems if your WS are hosted on different domains by that of Access-Control-Allow-Origin.

Here I leave some information about it. WHAT IS TOKEN-BASED AUTHENTICATION?

I also recommend this module for angular, it is very simple and it is easy to integrate with different OAuth2 authentication systems Satellizer

Greetings.

 1
Author: Alfredo Gt, 2016-09-20 23:51:27