amazon-archives / aws-cognito-angular-quickstart

An Angular(v5)-based QuickStart single-page app utilizing Amazon Cognito, S3, and DynamoDB (Serverless architecture)
https://cognito.budilov.com
Apache License 2.0
689 stars 304 forks source link

Decision to build in callbacks rather than use router guards? #88

Closed odinseyeanalytics closed 7 years ago

odinseyeanalytics commented 7 years ago

I have been looking for an efficient way to implement Angular 2/4 authorization/authentication models. This looks like a fantastic starting point - especially managing the initial login/registration steps.

However, I have a question about a design decision which differs from the angular.io demonstration model. That model shows that the authorization/validation step for pages should be built into the routes using route guards like canActivate() and canLoad() (see: https://angular.io/guide/router#milestone-5-route-guards) rather than per-component callbacks. Is there a benefit to this model with callbacks? Is building that content into the router module a recent Angular addition?

vbudilov commented 7 years ago

Hi @odinseyeanalytics ,

I would defer the angular best-practices to the angular community, rather than to this github repo. I'd like to discuss bugs/feature requests here. Best-practices are definitely important, but not the point of this particular project.

Also, I wrote the code more than a year ago, when angular2 was still in beta, so many things changed since then :)

Regards, Vladimir Budilov

fcaceres commented 6 years ago

use always angular guards. use the connection file to code your guards depending on the responses you get from cognito. Make your solution agnostic, so if you have to change the authentication, you could. That way you will have a more solid code. I did it that way, I didn't use this quickstart template.