Skip to content

Commit 1ed09f4

Browse files
committed
Refactoring.
1 parent 821839a commit 1ed09f4

File tree

7 files changed

+20
-38
lines changed

7 files changed

+20
-38
lines changed

app/Http/routes.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@
3535
Route::resource('/api/todo', 'TodoController');
3636
Route::resource('/api/user', 'UserController');
3737

38-
//Route::controllers([
39-
// 'api/auth' => 'Auth\AuthController',
40-
// 'api/password' => 'Auth\PasswordController',
41-
//]);
42-
4338
// Catch all undefined routes. Always gotta stay at the bottom since order of routes matters.
4439
Route::any('{undefinedRoute}', function ($undefinedRoute) {
4540
return view('layout');
4641
})->where('undefinedRoute', '([A-z\d-\/_.]+)?');
4742

48-
Blade::setContentTags('<%', '%>'); // for variables and all things Blade
49-
Blade::setEscapedContentTags('<%%', '%%>'); // for escaped data
43+
// Using different syntax for Blade to avoid conflicts with Jade.
44+
// You are well-advised to go without any Blade at all.
45+
Blade::setContentTags('<%', '%>'); // For variables and all things Blade.
46+
Blade::setEscapedContentTags('<%%', '%%>'); // For escaped data.

resources/js/app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ angular.module('todoApp', [
88
'TodoController',
99
'UserController',
1010
'UserService',
11-
'AuthService',
1211
'TodoService',
13-
'SessionService'
1412
]);
1513

resources/js/appRoutes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', '
2020
.otherwise({
2121
redirectTo: '/'
2222
});
23+
2324
$locationProvider.html5Mode(true);
2425

2526
$httpProvider.interceptors.push(['$rootScope', '$q', '$localStorage',
@@ -32,11 +33,11 @@ angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', '
3233
}
3334
return config;
3435
},
35-
response: function (response) {
36-
if (response.status === 401) {
37-
// handle the case where the user is not authenticated
36+
response: function (res) {
37+
if (res.status === 401) {
38+
// Handle unauthenticated user.
3839
}
39-
return response || $q.when(response);
40+
return res || $q.when(res);
4041
}
4142
};
4243
}

resources/js/controllers/MainController.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ angular.module('MainController', []).controller('MainController', ['$scope', '$l
1010
return route === $location.path();
1111
};
1212

13+
/**
14+
* Query the authenticated user by the Authorization token from the header.
15+
*
16+
* @param user {object} If provided, it won't query from database, but take this one.
17+
* @returns {null}
18+
*/
1319
$scope.getAuthenticatedUser = function (user) {
1420
if (user) {
1521
$scope.authenticatedUser = user;
@@ -21,11 +27,9 @@ angular.module('MainController', []).controller('MainController', ['$scope', '$l
2127
}
2228

2329
new User().$getByToken(function (user) {
24-
console.log(user);
2530
$scope.authenticatedUser = user;
2631
}, function (err) {
27-
//console.log(err);
28-
//$scope.authenticatedUser = err;
32+
console.log(err);
2933
});
3034
};
3135

resources/js/controllers/TodoController.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ angular.module('TodoController', []).controller('TodoController', ['$scope', '$l
1111
console.log(err);
1212
});
1313
};
14+
1415
$scope.find = function () {
1516
$scope.todos = Todo.query();
1617
};
18+
1719
$scope.remove = function (todo) {
1820
todo.$remove(function (res) {
1921
if (res) {
@@ -27,12 +29,14 @@ angular.module('TodoController', []).controller('TodoController', ['$scope', '$l
2729
console.log(err);
2830
})
2931
};
32+
3033
$scope.update = function (todo) {
3134
todo.$update(function (res) {
3235
}, function (err) {
3336
console.log(err);
3437
});
3538
};
39+
3640
$scope.findOne = function () {
3741
var splitPath = $location.path().split('/');
3842
var todoId = splitPath[splitPath.length - 1];

resources/js/services/AuthService.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

resources/js/services/SessionService.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)