Created
September 12, 2016 16:16
-
-
Save unicodeveloper/a7211e859d7081636025ffad679432f6 to your computer and use it in GitHub Desktop.
Cloudinary Blog Post - part 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appRoutes = angular.module('appRoutes', []); | |
appRoutes.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){ | |
$routeProvider | |
.when('/', { | |
templateUrl: './views/pages/home.client.view.html' | |
}) | |
.when('/auth/signup', { | |
templateUrl: './views/account/create-user.client.view.html', | |
controller: 'AuthController', | |
resolve: { | |
skipIfLoggedIn: skipIfLoggedIn | |
} | |
}) | |
.when('/auth/login', { | |
templateUrl: './views/account/login.client.view.html', | |
controller: 'AuthController', | |
resolve: { | |
skipIfLoggedIn: skipIfLoggedIn | |
} | |
}) | |
.when('/logout', { | |
template: null, | |
controller: 'LogoutCtrl', | |
resolve: { | |
loginRequired: loginRequired | |
} | |
}) | |
.when('/account', { | |
templateUrl: './views/account/edit-account.client.view.html', | |
controller: 'ProfileController', | |
resolve: { | |
loginRequired: loginRequired | |
} | |
}) | |
.when('/page/about', { | |
templateUrl: './views/pages/about.client.view.html' | |
}) | |
.otherwise({ redirectTo: '/' }); | |
function skipIfLoggedIn($q, $auth) { | |
var deferred = $q.defer(); | |
if ($auth.isAuthenticated()) { | |
deferred.reject(); | |
} else { | |
deferred.resolve(); | |
} | |
return deferred.promise; | |
} | |
function loginRequired($q, $location, $auth) { | |
var deferred = $q.defer(); | |
if ($auth.isAuthenticated()) { | |
deferred.resolve(); | |
} else { | |
$location.path('/auth/login'); | |
} | |
return deferred.promise; | |
} | |
//eliminate the hashbang | |
$locationProvider.html5Mode(true); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment