1

Recently I have been doing a lot of development with Angular 2. I was working on creating a project that was going to be solely a website but now that I have found Ionic 2 I am thinking I should go that way. It would be nice to have the app's along with the website but there are some things that I am not sure about. The main thing is in Angular 2 you can use Auth guards to block routes if a user is not logged in. Is this something I need to worry about when creating my ionic app? I would like to be able to run my app as a website, an android app, and ios app. If it is unnecessary that would be nice but I assume it would be needed for at least the website. Thanks for all the help!

rpascal
  • 723
  • 1
  • 8
  • 25

1 Answers1

3

ionic2 doesn't use authguards. (since it doesn't work with angular's route system). I don't think that it's necessary as well, since Ionic doesn't use URL's, but rather goes with the NavController and navigation stack for routing.

This means that you cannot reach a page if you aren't 'pushed' towards it.

If this doesn't work or if it poses a security threat you will probably need to check on each component whether or not the user is logged in (oauth key could be stored in localStorage for example).

But initially, if you have for example a Page2Component, your html file cannot be accessed by going to localhost:3000/page2, but will stay on localhost:3000 and can only be reached when this.navCtrl.push(Page2Component) is called.

Ivar Reukers
  • 7,560
  • 9
  • 56
  • 99