Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/login/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

angular.module('supportAdminApp')
.controller('LoginController', [
'$scope', '$rootScope', '$location', '$state', 'AuthService', 'TokenService', 'UserV3Service',
function ($scope, $rootScope, $location, $state, $authService, $tokenService, $userV3Service) {
'$scope', '$rootScope', '$location', '$state', 'AuthService', 'TokenService', 'UserService',
function ($scope, $rootScope, $location, $state, $authService, $tokenService, $userService) {

$scope.loggingIn = false;

Expand All @@ -21,7 +21,7 @@ angular.module('supportAdminApp')
$scope.loggingIn = false;
return;
}
$userV3Service.loadUser().then(function(currentUser) {
$userService.findById(token.userId).then(function(currentUser) {
console.log('Login Success');
$rootScope.currentUser = currentUser;
$state.go('index.main')
Expand Down
41 changes: 40 additions & 1 deletion src/app/users/users.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,48 @@ angular.module('supportAdminApp')
.factory('UserService', ['$q','$http', 'API_URL',
function ($q, $http, API_URL) {
// local dev
//API_URL = 'http://local.topcoder-dev.com:8080';
return ({

/** find user by ID */
findById: function(userId) {
if(!userId) {
return $q.reject({error : 'userId must be specified.'});
}

var request = $http({
method: 'GET',
url: API_URL + '/v3/users/' + userId,
headers: {
"Content-Type":"application/json"
}
});

return request.then(
function(response) {
console.log(response);
return response.data.result.content;
},
function(error) {
console.log(error);
var err;
if(error && error.data && error.data.result) {
err = {
status: error.status,
error : error.data.result.content
};
}
if(!err) {
err = {
status: error.status,
error : error.statusText
};
}
return $q.reject(err);
}
);
}, // findById()


/** find users */
find: function(options) {
var opts = options || {};
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/topnavbar.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row border-bottom">
<nav class="navbar navbar-static-top white-bg" role="navigation" style="margin-bottom: 0">
<div ng-controller="MainController">
<div ng-controller="MainController" style="margin-right: 50px;">
<ul class="nav navbar-top-links navbar-right">
<li ng-show="authorized()">
<span class="clear">
Expand Down