Skip to content

Commit 5082a48

Browse files
author
Yoshifumi Kohata
committed
Merge pull request #1 from appirio-tech/COR-2015-11-16-PRE1
- Replaced /profiles/{id} with /users/{id} because profile service seems not to be deployed in the production.
2 parents fc67863 + c86f14a commit 5082a48

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

src/app/login/login.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
angular.module('supportAdminApp')
44
.controller('LoginController', [
5-
'$scope', '$rootScope', '$location', '$state', 'AuthService', 'TokenService', 'UserV3Service',
6-
function ($scope, $rootScope, $location, $state, $authService, $tokenService, $userV3Service) {
5+
'$scope', '$rootScope', '$location', '$state', 'AuthService', 'TokenService', 'UserService',
6+
function ($scope, $rootScope, $location, $state, $authService, $tokenService, $userService) {
77

88
$scope.loggingIn = false;
99

@@ -21,7 +21,7 @@ angular.module('supportAdminApp')
2121
$scope.loggingIn = false;
2222
return;
2323
}
24-
$userV3Service.loadUser().then(function(currentUser) {
24+
$userService.findById(token.userId).then(function(currentUser) {
2525
console.log('Login Success');
2626
$rootScope.currentUser = currentUser;
2727
$state.go('index.main')

src/app/users/users.service.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,48 @@ angular.module('supportAdminApp')
44
.factory('UserService', ['$q','$http', 'API_URL',
55
function ($q, $http, API_URL) {
66
// local dev
7-
//API_URL = 'http://local.topcoder-dev.com:8080';
87
return ({
98

9+
/** find user by ID */
10+
findById: function(userId) {
11+
if(!userId) {
12+
return $q.reject({error : 'userId must be specified.'});
13+
}
14+
15+
var request = $http({
16+
method: 'GET',
17+
url: API_URL + '/v3/users/' + userId,
18+
headers: {
19+
"Content-Type":"application/json"
20+
}
21+
});
22+
23+
return request.then(
24+
function(response) {
25+
console.log(response);
26+
return response.data.result.content;
27+
},
28+
function(error) {
29+
console.log(error);
30+
var err;
31+
if(error && error.data && error.data.result) {
32+
err = {
33+
status: error.status,
34+
error : error.data.result.content
35+
};
36+
}
37+
if(!err) {
38+
err = {
39+
status: error.status,
40+
error : error.statusText
41+
};
42+
}
43+
return $q.reject(err);
44+
}
45+
);
46+
}, // findById()
47+
48+
1049
/** find users */
1150
find: function(options) {
1251
var opts = options || {};

src/components/common/topnavbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="row border-bottom">
22
<nav class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
3-
<div ng-controller="MainController">
3+
<div ng-controller="MainController" style="margin-right: 50px;">
44
<ul class="nav navbar-top-links navbar-right">
55
<li ng-show="authorized()">
66
<span class="clear">

0 commit comments

Comments
 (0)