Discussion for angular (2+) - need help? create a stackblitz with your issue to get help faster using this template: https://stackblitz.com/fork/angular-issue-repro2
Let’s say I'll put some data into route that will show that this route needs auth.
Is there some global way to intercept navigation to that route and
1) Find out if that route needs an auth
2) Redirect to login page if there is no auth
3) Of course component that represents that route should not be created if there is no auth
3) View should not be rendered if there is no auth
@CanActivate can do similar thing, but it needs to be added on components. I'm looking for a way to avoid that copy-paste on every component
@robwormald one last bit of functionality, there's also this command
grecaptcha.reset(
opt_widget_id
)
Just in case you need to reset captcha, for instance if the person has completed the captcha but still entered in the wrong password. So I'm assuming you'd need to pass that command from the component into the directive? How would do we go about that?
signin(login:string, password:string):Observable {
var data = {
login: login,
password: password
};
return this.http.put('/api/v1/auth', JSON.stringify(data))
.map(res => res.json());
}