Skip to content

Commit

Permalink
Step 4.9: Add resolve to auth routes
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and Dotan Simha committed Nov 23, 2016
1 parent 11d3b90 commit 77faaf8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions client/scripts/routes.js
Expand Up @@ -8,12 +8,21 @@ import profileTemplateUrl from '../templates/profile.html';
import tabsTemplateUrl from '../templates/tabs.html';

export default class RoutesConfig extends Config {
constructor() {
super(...arguments);

this.isAuthorized = ['$auth', this.isAuthorized.bind(this)];
}

configure() {
this.$stateProvider
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: tabsTemplateUrl
templateUrl: tabsTemplateUrl,
resolve: {
user: this.isAuthorized
}
})
.state('tab.chats', {
url: '/chats',
Expand Down Expand Up @@ -46,11 +55,18 @@ export default class RoutesConfig extends Config {
.state('profile', {
url: '/profile',
templateUrl: profileTemplateUrl,
controller: 'ProfileCtrl as profile'
controller: 'ProfileCtrl as profile',
resolve: {
user: this.isAuthorized
}
});

this.$urlRouterProvider.otherwise('tab/chats');
}

isAuthorized($auth) {
return $auth.awaitUser();
}
}

RoutesConfig.$inject = ['$stateProvider', '$urlRouterProvider'];

0 comments on commit 77faaf8

Please sign in to comment.