TL;DR How does CanActivate work?
Long version It is the first time that I see the implementation of a client-side access control.
In all the authentication systems that I used so far (e.g. PHP or other server side programming language), there's always been a function that checks if the user is already logged in, if such function returns true the server can deliver the page, otherwise the user get redirected to a login page.
In this case the client can't access the server code, it can only makes requests and wait until the server composes the page, then render it.
Instead, Angular works differently. It is a client-side framework which uses JavaScript, and its code is visible by everyone. The private page isn't securely placed inside the server, the only server task is to deliver the SPA, but it can't accept further requests.
Despite it, the framework implements features as CanActivate, and it works well. So I was wondering about what forbids me to inject some JavaScript code and access a private page, even if I don't have the right, or more generally how this system works. On the Internet I didn't find enough information and I don't have enough skills to understand the source code. Can you help me to clarify my ideas?
I could just ask the question in the title, but I preferred to tell you everything I know, so if there's something wrong you can correct me. Thank you