There is a typical login / password form. Submitting a form to submit is intercepted in angular, then an ajax request is sent to the server and, if the status is OK, I do window.location.replace (...) i.e. I reload the page to the address I need and the user enters it already logged in. Is it correct and safe, or should you still submit submit directly to the server?

  • This can be done and the redirector from the server. - raviga

2 answers 2

XHR does not redirect, i.e. when using Angular, redirection is possible only on the client. Thus, this code will be stored in JS, which allows its viewing and modification. What can be done with this is another question - maybe nothing. If you use a regular submit, you can redirect to login success / failure on the server.

    Theoretically it can be so. It is important to understand how backing in chat tokens cookies, etc. work. Based on this, after receiving the answer, enter the data on the client and update the page.

    But this is a crutch method. If you do not want to fully use angular, then use only validation and other local buns, and send already through the server.

    The best option would be to completely divide into two applications - the client, the server, and set up communication through an apishka with the exchange / verification of tokens.

    At one time I also tried to soften the transition by gradually introducing an angular, I spent more time.