Skip to content

Commit 5e11af8

Browse files
committed
Moving Spigit Client Secret from config to the UI.
1 parent 4a60972 commit 5e11af8

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ The following configuration parameters are available:
3636
| JWT_V2_NAME | jwt V2 cookie name |
3737
| OAUTH2_TOKEN_NAME | OAuth2 token name |
3838
| OAUTH2_TOKEN_EXPIRETIME_TAGNAME | OAuth2 token expire time tag name |
39-
| OAUTH2_CLIENT_SECRET | OAuth2 client secret |
4039
| SPIGIT_API_URL | SPIGIT api base url |
4140
|SPIGIT_API_VERSION_PATH | SPIGIT api version path |
4241

config.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"JWT_V2_NAME": "tcjwt",
1111
"OAUTH2_TOKEN_NAME": "oa2spigit",
1212
"OAUTH2_TOKEN_EXPIRETIME_TAGNAME": "oa2expire",
13-
"OAUTH2_CLIENT_SECRET": "qTyeKfuKB7h3CG6tVFJf3QIoMpmp4gnliRupMAM2jEqGjqYR",
1413
"SPIGIT_API_URL": "spigit.com",
1514
"SPIGIT_API_VERSION_PATH" : "/api/v1"
1615
},
@@ -25,7 +24,6 @@
2524
"JWT_V2_NAME": "tcjwt",
2625
"OAUTH2_TOKEN_NAME": "oa2spigit",
2726
"OAUTH2_TOKEN_EXPIRETIME_TAGNAME": "oa2expire",
28-
"OAUTH2_CLIENT_SECRET": "qTyeKfuKB7h3CG6tVFJf3QIoMpmp4gnliRupMAM2jEqGjqYR",
2927
"SPIGIT_API_URL": "spigit.com",
3028
"SPIGIT_API_VERSION_PATH" : "/api/v1"
3129
},
@@ -40,7 +38,6 @@
4038
"JWT_V2_NAME": "tcjwt",
4139
"OAUTH2_TOKEN_NAME": "oa2spigit",
4240
"OAUTH2_TOKEN_EXPIRETIME_TAGNAME": "oa2expire",
43-
"OAUTH2_CLIENT_SECRET": "qTyeKfuKB7h3CG6tVFJf3QIoMpmp4gnliRupMAM2jEqGjqYR",
4441
"SPIGIT_API_URL": "spigit.com",
4542
"SPIGIT_API_VERSION_PATH" : "/api/v1"
4643
},
@@ -55,7 +52,6 @@
5552
"JWT_V2_NAME": "tcjwt",
5653
"OAUTH2_TOKEN_NAME": "oa2spigit",
5754
"OAUTH2_TOKEN_EXPIRETIME_TAGNAME": "oa2expire",
58-
"OAUTH2_CLIENT_SECRET": "qTyeKfuKB7h3CG6tVFJf3QIoMpmp4gnliRupMAM2jEqGjqYR",
5955
"SPIGIT_API_URL": "spigit.com",
6056
"SPIGIT_API_VERSION_PATH" : "/api/v1"
6157
}

src/app/ideas/ideas.detail.controller.js

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

33
var module = angular.module('supportAdminApp');
44

5-
module.controller('IdeasDetailController', ['$scope', '$log','IdeaService', 'Alert', '$timeout', 'OAuth2Service','$uibModalInstance', 'ideaId', 'domain', 'username', 'password', 'clientId', '$sce', 'SPIGIT_API_URL',
6-
function ($scope, $log, IdeaService, $alert, $timeout, OAuth2Service, $modalInstance, ideaId, domain, username, password, clientId, $sce, SPIGIT_API_URL) {
5+
module.controller('IdeasDetailController', ['$scope', '$log','IdeaService', 'Alert', '$timeout', 'OAuth2Service','$uibModalInstance', 'ideaId', 'domain', 'username', 'password', 'clientId', 'clientSecret', '$sce', 'SPIGIT_API_URL',
6+
function ($scope, $log, IdeaService, $alert, $timeout, OAuth2Service, $modalInstance, ideaId, domain, username, password, clientId, clientSecret, $sce, SPIGIT_API_URL) {
77

88
$scope.ideaId = ideaId;
99
$scope.domain = domain;
1010
$scope.username = username;
1111
$scope.password = password;
1212
$scope.clientId = clientId;
13+
$scope.clientSecret = clientSecret;
1314

1415
$scope.form = {};
1516
$scope.isLoading = false;
@@ -20,7 +21,7 @@ module.controller('IdeasDetailController', ['$scope', '$log','IdeaService', 'Al
2021

2122
// If token expired should get new token first
2223
if (OAuth2Service.checkTokenExpireTime()) {
23-
OAuth2Service.refreshToken($scope.username, $scope.password, $scope.domain, $scope.clientId).then(function (data) {
24+
OAuth2Service.refreshToken($scope.username, $scope.password, $scope.domain, $scope.clientId, $scope.clientSecret).then(function (data) {
2425
$scope.loadDetail();
2526
}).catch(function (error) {
2627
$alert.error(error.message, $scope);

src/app/ideas/ideas.list.controller.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ module.controller('IdeaListController', ['$scope', '$rootScope', '$log','IdeaSer
4545
* Refresh OAuth Token
4646
*/
4747
$scope.refreshToken = function () {
48-
OAuth2Service.refreshToken($scope.formSearch.criteria.username, $scope.formSearch.criteria.password, $scope.formSearch.criteria.domain, $scope.formSearch.criteria.clientId).then(function (data) {
48+
OAuth2Service.refreshToken($scope.formSearch.criteria.username,
49+
$scope.formSearch.criteria.password,
50+
$scope.formSearch.criteria.domain,
51+
$scope.formSearch.criteria.clientId,
52+
$scope.formSearch.criteria.clientSecret).then(function (data) {
4953
$scope.currentDomain = $scope.formSearch.criteria.domain;
5054
$scope.search();
5155
}).catch(function (error) {
@@ -65,6 +69,7 @@ module.controller('IdeaListController', ['$scope', '$rootScope', '$log','IdeaSer
6569
username: function () { return $scope.formSearch.criteria.username; },
6670
password: function () { return $scope.formSearch.criteria.password; },
6771
clientId: function () { return $scope.formSearch.criteria.clientId; },
72+
clientSecret: function () { return $scope.formSearch.criteria.clientSecret; },
6873
}
6974
});
7075
}

src/app/ideas/ideas.list.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@
1919
</div>
2020
</div>
2121
<div class="row">
22-
<div class="form-group col-md-6" ng-class="{'has-error': formSearch.criteria.domain.$touched && formSearch.criteria.domain.$invalid}">
22+
<div class="form-group col-md-3" ng-class="{'has-error': formSearch.criteria.domain.$touched && formSearch.criteria.domain.$invalid}">
2323
<label for="domain">Domain</label>
2424
<input id="domain" type="text" class="form-control" ng-keyup="onDomainKeyUp($event)" ng-model="formSearch.criteria.domain" name="domain" required>
2525
</div>
26-
<div class="form-group col-md-6" ng-class="{'has-error': formSearch.criteria.clientId.$touched && formSearch.criteria.clientId.$invalid}">
26+
<div class="form-group col-md-3" ng-class="{'has-error': formSearch.criteria.clientId.$touched && formSearch.criteria.clientId.$invalid}">
2727
<label for="clientId">Client Id</label>
2828
<input id="clientId" type="text" class="form-control" ng-model="formSearch.criteria.clientId" name="clientId" required>
2929
</div>
30+
<div class="form-group col-md-6" ng-class="{'has-error': formSearch.criteria.clientSecret.$touched && formSearch.criteria.clientSecret.$invalid}">
31+
<label for="clientSecret">Client Secret</label>
32+
<input id="clientSecret" type="password" class="form-control" ng-model="formSearch.criteria.clientSecret" name="clientSecret" required>
33+
</div>
3034
</div>
3135
<div class="row">
3236
<div class="form-group col-md-6" ng-class="{'has-error': formSearch.criteria.communityId.$touched && formSearch.criteria.communityId.$invalid}">

src/app/ideas/oauth2.service.js

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

33
angular.module('supportAdminApp')
4-
.factory('OAuth2Service', ['$q', '$log', '$http', 'helper', '$cookies', '$state', 'OAUTH2_TOKEN_NAME', 'COOKIES_SECURE', 'OAUTH2_CLIENT_SECRET', 'SPIGIT_API_URL', 'OAUTH2_TOKEN_EXPIRETIME_TAGNAME', 'moment',
5-
function($q, $log, $http, helper,$cookies, $state, OAUTH2_TOKEN_NAME, COOKIES_SECURE, OAUTH2_CLIENT_SECRET, SPIGIT_API_URL, OAUTH2_TOKEN_EXPIRETIME_TAGNAME, moment) {
4+
.factory('OAuth2Service', ['$q', '$log', '$http', 'helper', '$cookies', '$state', 'OAUTH2_TOKEN_NAME', 'COOKIES_SECURE', 'SPIGIT_API_URL', 'OAUTH2_TOKEN_EXPIRETIME_TAGNAME', 'moment',
5+
function($q, $log, $http, helper,$cookies, $state, OAUTH2_TOKEN_NAME, COOKIES_SECURE, SPIGIT_API_URL, OAUTH2_TOKEN_EXPIRETIME_TAGNAME, moment) {
66

77
var OAuth2Service = { };
88

@@ -12,16 +12,17 @@ angular.module('supportAdminApp')
1212
* @param password
1313
* @param domain
1414
* @param clientId
15+
* @param clientSecret
1516
* @returns {Promise<any>}
1617
*/
17-
OAuth2Service.refreshToken = function(username, password, domain, clientId) {
18+
OAuth2Service.refreshToken = function(username, password, domain, clientId, clientSecret) {
1819

1920
var params = {
2021
grant_type: 'password',
2122
username: username,
2223
password: password,
2324
client_id : clientId,
24-
client_secret: OAUTH2_CLIENT_SECRET
25+
client_secret: clientSecret
2526
};
2627
const searchParams = Object.keys(params).map(function (key) {
2728
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);

0 commit comments

Comments
 (0)