Skip to content

Commit 6c56fc9

Browse files
Fix errors
1 parent 5c3849b commit 6c56fc9

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

angular/app.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
(function() {
2-
2+
33
'use strict';
4-
4+
55
angular.module('authApp', ['auth0', 'angular-storage', 'angular-jwt', 'ngMaterial', 'ui.router'])
66
.config(function($provide, authProvider, $urlRouterProvider, $stateProvider, $httpProvider, jwtInterceptorProvider) {
7-
7+
88
authProvider.init({
9-
domain: 'YOUR_AUTH0_DOMAIN',
10-
clientID: 'YOUR_AUTH0_CLIENT_ID'
9+
domain: 'unicodeveloper.auth0.com',
10+
clientID: 'mOh81XhUQvqeQ1uVY2yvgERpKKQjSKQr'
1111
});
12-
12+
13+
14+
1315
$urlRouterProvider.otherwise("/home");
14-
16+
1517
$stateProvider
1618
.state('home', {
1719
url: '/home',
@@ -22,15 +24,21 @@
2224
templateUrl: 'components/profile/profile.tpl.html',
2325
controller: 'profileController as user'
2426
});
25-
27+
2628
jwtInterceptorProvider.tokenGetter = function(store) {
2729
return store.get('token');
2830
}
29-
30-
function redirect($q, $injector, auth, store, $location) {
31+
32+
function redirect($q, $injector, $timeout, store, $location) {
33+
34+
var auth;
35+
$timeout(function() {
36+
auth = $injector.get('auth');
37+
});
38+
3139
return {
3240
responseError: function(rejection) {
33-
41+
3442
if (rejection.status === 401) {
3543
auth.signout();
3644
store.remove('profile');
@@ -46,7 +54,7 @@
4654
$httpProvider.interceptors.push('redirect');
4755
})
4856
.run(function($rootScope, $state, auth, store, jwtHelper, $location) {
49-
57+
5058
$rootScope.$on('$locationChangeStart', function() {
5159
// Get the JWT that is saved in local storage
5260
// and if it is there, check whether it is expired.
@@ -57,14 +65,14 @@
5765
if (!auth.isAuthenticated) {
5866
auth.authenticate(store.get('profile'), token);
5967
}
60-
}
61-
}
62-
else {
68+
}
69+
}
70+
else {
6371
// Otherwise, redirect to the home route
6472
$location.path('/home');
6573
}
6674
});
67-
75+
6876
});
69-
77+
7078
})();

angular/components/profile/profile.ctr.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// does not require authentication. We can
2020
// avoid sending the JWT as an Authorization
2121
// header with skipAuthorization: true
22-
function getMessage() {
22+
function getPublicQuote() {
2323
$http.get('http://localhost:1337/api/random-quote', {
2424
skipAuthorization: true
2525
}).then(function(response) {
@@ -30,7 +30,7 @@
3030
// Makes a call to a private endpoint that does
3131
// require authentication. The JWT is automatically
3232
// sent with HTTP calls using jwtInterceptorProvider in app.js
33-
function getSecretMessage() {
33+
function getSecretQuote() {
3434
$http.get('http://localhost:1337/api/protected/random-quote').then(function(response) {
3535
vm.message = response.data.quote;
3636
});
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<md-toolbar>
2-
<div class="md-toolbar-tools">
2+
<div class="md-toolbar-tools">
33
<h2>
4-
<span>Angular Auth</span>
4+
<span>Get Chuck Norris Quotes</span>
55
</h2>
66
<span flex></span>
7-
7+
88
<md-button
99
aria-label="Login"
1010
ng-if="!toolbar.auth.isAuthenticated"
1111
ng-click="toolbar.login()">
1212
Login
1313
</md-button>
14-
14+
1515
<md-button
1616
ui-sref="profile"
1717
ng-if="toolbar.auth.isAuthenticated"
1818
aria-label="Profile">
1919
Profile
2020
</md-button>
21-
21+
2222
<md-button
2323
aria-label="Logout"
2424
ng-if="toolbar.auth.isAuthenticated"
2525
ng-click="toolbar.logout()">
2626
Logout
2727
</md-button>
28-
29-
</div>
28+
29+
</div>
3030
</md-toolbar>

views/layout.ejs

-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989

9090
<!--SCRIPTS-->
9191
<script src="/js/dependencies/sails.io.js"></script>
92-
<script src="/bower_components/jquery/dist/jquery.js"></script>
93-
<script src="/bower_components/angular/angular.js"></script>
94-
<script src="/bower_components/angular-route/angular-route.js"></script>
95-
<script src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
9692
<script src="/js/app.js"></script>
9793
<!--SCRIPTS END-->
9894
</body>

0 commit comments

Comments
 (0)