Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit e7e894b

Browse files
author
Sachin Maheshwari
committed
removing v2 api dependency
1 parent 7359872 commit e7e894b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/front/src/components/common/navigation.controller.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
'use strict';
22

33
angular.module('topcoderX') // eslint-disable-line angular/no-services
4-
.controller('NavController', ['$scope', '$log', '$state', '$cookies', '$http', '$rootScope',
5-
function ($scope, $log, $state, $cookies, $http, $rootScope) {
4+
.controller('NavController', ['$scope', '$log', '$state', '$cookies', 'jwtHelper', '$rootScope',
5+
function ($scope, $log, $state, $cookies, jwtHelper, $rootScope) {
66
$scope.$state = $state;
77
$scope.menuList = false;
88
$scope.user = {};
99
$scope.appConfig = $rootScope.appConfig;
1010

1111
const token = $cookies.get('tcjwt');
12-
const req = {
13-
url: $rootScope.appConfig.TC_USER_PROFILE_URL,
14-
method: 'Get',
15-
headers: {
16-
Authorization: 'Bearer ' + token,
17-
},
18-
};
19-
$http(req).then(function (tcUser) {
20-
$scope.user = tcUser.data;
21-
if (tcUser.data.copilot) {
22-
$log.info('Success - user is a copilot');
23-
} else {
24-
$log.warn('Warning - User isn\'t a a copilot');
12+
const decodedToken = jwtHelper.decodeToken(token);
13+
$scope.user = {};
14+
$scope.user['copilot'] = false;
15+
Object.keys(decodedToken).findIndex(function (key) {
16+
if (key.includes('roles')) {
17+
if (decodedToken['roles'].indexOf('copilot') > -1) {
18+
$scope.user['copilot'] = true;
19+
$log.info('User is a copilot');
20+
} else {
21+
$log.info('user is not a copilot');
22+
}
23+
return true;
2524
}
25+
return false;
2626
});
2727

2828
$scope.forceStateProjects = function () {

0 commit comments

Comments
 (0)