Log in to Angular2

Asked

Viewed 599 times

4

I’m starting to learn angular2 and I have a few questions about how to log in to an application.

For example I in php make a query with the variables I receive by post I check if they exist, if they exist I create a session and on all pages I check whether the session is active.

In the angular2 I don’t know how to do this. Someone can help me?

  • A complete example with login: http://kazale.com/curso-angular-2-aula-1-creation-firstapplication/

1 answer

7


Hello, MANIAMAX!

This doubt is frequent in angular beginners, especially those coming from php back-end and the like.

The angular form of authentication is done using tokens. You will make a request pro server with email and password. From this, the server does the checking and if it is ok, it will send a token. This token must be saved by the client.

And what to do with this token?

You will use it to check the login.

The way to detect this token on the server can be several. You can enter it in the request itself, send it as a parameter or check the browser cache.

Token is unique to each user.

I hope you’ve solved your doubt. I could give you an example, but from what I understand, your doubt is more about how it works than how it works.

  • 1

    Set the example anyway, it will enrich your answer.

  • Would you have an example Pedro? I’m new to the framework

  • funny that everyone knows how to explain but no one can put an example

Browser other questions tagged

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