Let's now build an Ionic application that will handle both authentication and authorization. Authorization refers to rules that determine who is allowed to do what. Authentication and authorization are central parts of securing an application:
Authentication = login + password (who you are)
Authorization = permissions (what you are allowed to do)
In this section, we will see how we can secure views of the Ionic application that are login protected. We will be working on the following points:
- HomePage will be public
- ArticlesPage is protected and will only be accessed after login
- Menu is also dynamically updated on auth status
- LoginPage will be inaccessible once a user is loggedIn
- Authorization header will be passed after login for each request
Let's start by creating the application and I have named it as ionic2-auth:
$ ionic start ionic2-auth sidemenu -v2
$ ionic...