Is it possible to authenticate with Angularjs?

Asked

Viewed 92 times

4

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

1 answer

3


I didn’t 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 server-side authentication is positive, I return a user object with the information that is required to save to the WEB. to save this information on the web, I use Sessionstorage, I could also save in Localstorage, this goes of your need.

Follow example below p/ include the same in sessionStorage.

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

    sessionStorage.setItem('userLogado', retornoSucesso.data) //objeto de usuário que utilizo.
});
  • A question, how to recover the logged in user(Object) from session?

  • 1

    sessionStorage.getItem('userLogado') @Techies

Browser other questions tagged

You are not signed in. Login or sign up in order to post.