Is it possible to authenticate with angularJS?

4

Is it possible to authenticate with Angular and recover the logged in user? If possible what is the best practice to do?

    
asked by anonymous 28.09.2015 / 22:10

1 answer

3

I did not quite understand your question, but I will apply an answer that I use.

I authenticate a user with the server, using the http service, and if the server side authentication is positive, I return a user object with the information that is necessary to save on the WEB. to save this information on the WEB, I use the SessionStorage, could also save in LocalStorage, this goes beyond your need.

Follow the example below to include the same in sessionStorage.

$http.post('url', objeto).then(function(retornoSucesso) {

    sessionStorage.setItem('userLogado', retornoSucesso.data) //objeto de usuário que utilizo.
});
    
29.09.2015 / 01:08