embed.plnkr.co/Mvrte4/preview

This link shows an example of simple authorization using AngularJS.

The problem is that if you log in, and then refresh the page, then it rolls me back to the login page.

Tell me what the problem is, how to solve it?

  • remove all unnecessary from the example and insert the code directly into the question - Grundy
  • I can not delete anything, because it's all necessary for normal work - angryblacker
  • of course you can. Delete everything that is not required to demonstrate the problem. - Grundy

1 answer 1

It would be better to leave a response in the comments, but so far the reputation is not enough. You store the data in session.js, the scope of which is updated when the page is updated. Accordingly, there is no more data about the user in the session after the page has been updated, since it is rendered again.

  • What can be done to avoid this problem? If I understand correctly, do I need the data to be stored on the backend? - angryblacker
  • Backend is a good option in my opinion. Look for information on the Internet for authorization. As one of the options, you can add information about the session to the database. You can also use localStorage, which allows you to store data in a browser without accessing the backend. - user5554178