Skip to content

Commit

Permalink
applies small enhancements and code style
Browse files Browse the repository at this point in the history
as was commented by deepu

PR #3324
  • Loading branch information
David Steiman committed Apr 12, 2016
1 parent 572aadc commit d7a296f
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 102 deletions.
2 changes: 1 addition & 1 deletion generators/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ module.exports = JhipsterClientGenerator.extend({
this.template(ANGULAR_DIR + 'components/util/_jhi-item-count.directive.js', ANGULAR_DIR + 'components/util/jhi-item-count.directive.js', this, {});

// interceptor code
if (this.authenticationType === 'oauth2' || this.authenticationType === 'jwt' || this.authenticationType == 'uaa') {
if (this.authenticationType === 'oauth2' || this.authenticationType === 'jwt' || this.authenticationType === 'uaa') {
this.template(ANGULAR_DIR + 'blocks/interceptor/_auth.interceptor.js', ANGULAR_DIR + 'blocks/interceptor/auth.interceptor.js', this, {});
}
this.template(ANGULAR_DIR + 'blocks/interceptor/_auth-expired.interceptor.js', ANGULAR_DIR + 'blocks/interceptor/auth-expired.interceptor.js', this, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$urlRouterProvider.otherwise('/');

$httpProvider.interceptors.push('errorHandlerInterceptor');
$httpProvider.interceptors.push('authExpiredInterceptor');<% if (authenticationType == 'oauth2' || authenticationType == 'jwt' || authenticationType == 'uaa') { %>
$httpProvider.interceptors.push('authExpiredInterceptor');<% if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { %>
$httpProvider.interceptors.push('authInterceptor');<% } %>
$httpProvider.interceptors.push('notificationInterceptor');
// jhipster-needle-angularjs-add-interceptor JHipster will add new application http interceptor here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Account.$inject = ['$resource'];

function Account ($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/account'<%} else { %>'api/account'<% } %>, {}, {
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/account'<%} else { %>'api/account'<% } %>, {}, {
'get': { method: 'GET', params: {}, isArray: false,
interceptor: {
response: function(response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Activate.$inject = ['$resource'];

function Activate ($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/activate'<%} else { %>'api/activate'<% } %>, {}, {
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/activate'<%} else { %>'api/activate'<% } %>, {}, {
'get': { method: 'GET', params: {}, isArray: false}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

function login (credentials) {
<% if(authenticationType == 'uaa') { %>
<% if(authenticationType === 'uaa') { %>
var data = {
username: credentials.username,
password: credentials.password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
.module('<%=angularAppName%>')
.factory('AuthServerProvider', AuthServerProvider);

AuthServerProvider.$inject = ['$http', '$localStorage' <% if (websocket == 'spring-websocket') { %>, '<%=jhiPrefixCapitalized%>TrackerService'<% } %>];
AuthServerProvider.$inject = ['$http', '$localStorage' <% if (websocket === 'spring-websocket') { %>, '<%=jhiPrefixCapitalized%>TrackerService'<% } %>];

function AuthServerProvider ($http, $localStorage <% if (websocket == 'spring-websocket') { %>, <%=jhiPrefixCapitalized%>TrackerService<% } %>) {
function AuthServerProvider ($http, $localStorage <% if (websocket === 'spring-websocket') { %>, <%=jhiPrefixCapitalized%>TrackerService<% } %>) {
var service = {
getToken: getToken,
hasValidToken: hasValidToken,
Expand Down Expand Up @@ -41,10 +41,10 @@
});
}

function logout () {<% if (websocket == 'spring-websocket') { %>
function logout () {<% if (websocket === 'spring-websocket') { %>
<%=jhiPrefixCapitalized%>TrackerService.disconnect();<% } %>

<% if(authenticationType == 'uaa') { %>
<% if(authenticationType === 'uaa') { %>
delete $localStorage.authenticationToken;
<% } else { %>
// logout from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PasswordResetFinish.$inject = ['$resource'];

function PasswordResetFinish($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/account/reset_password/finish'<%} else { %>'api/account/reset_password/finish'<% } %>, {}, {});
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/account/reset_password/finish'<%} else { %>'api/account/reset_password/finish'<% } %>, {}, {});

return service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PasswordResetInit.$inject = ['$resource'];

function PasswordResetInit($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/account/reset_password/init'<%} else { %>'api/account/reset_password/init'<% } %>, {}, {});
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/account/reset_password/init'<%} else { %>'api/account/reset_password/init'<% } %>, {}, {});

return service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Password.$inject = ['$resource'];

function Password($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/account/change_password'<%} else { %>'api/account/change_password'<% } %>, {}, {});
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/account/change_password'<%} else { %>'api/account/change_password'<% } %>, {}, {});

return service;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
Register.$inject = ['$resource'];

function Register ($resource) {
return $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/register'<%} else { %>'api/register'<% } %>, {}, {});
return $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/register'<%} else { %>'api/register'<% } %>, {}, {});
}
})();
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
User.$inject = ['$resource'];

function User ($resource) {
var service = $resource(<% if(authenticationType == 'uaa') { %>'<%= uaaBaseName %>/api/users/:login'<%} else { %>'api/users/:login'<% } %>, {}, {
var service = $resource(<% if(authenticationType === 'uaa') { %>'<%= uaaBaseName %>/api/users/:login'<%} else { %>'api/users/:login'<% } %>, {}, {
'query': {method: 'GET', isArray: true},
'get': {
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Service Tests', function () {
sessionStorageService = $sessionStorage;
authService = Auth;
spiedAuthServerProvider = AuthServerProvider;
<%_ if (authenticationType != 'jwt' && authenticationType != 'uaa') { _%>
<%_ if (authenticationType !== 'jwt' && authenticationType !== 'uaa') { _%>
$httpBackend.expectPOST(/api\/logout\?cacheBuster=\d+/).respond(200, '');
<%_ } _%>
}));
Expand Down
18 changes: 9 additions & 9 deletions generators/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ module.exports = JhipsterServerGenerator.extend({
},
{
when: function (response) {
return applicationType === 'gateway' || applicationType == 'microservice';
return applicationType === 'gateway' || applicationType === 'microservice';
},
type: 'list',
name: 'authenticationType',
Expand All @@ -298,7 +298,7 @@ module.exports = JhipsterServerGenerator.extend({
},
{
value: 'uaa',
name: 'Authentication via JHipster UAA (you will have to generate one separately)'
name: 'Authentication via JHipster UAA (you will have to generate app separately)'
}
],
default: 0
Expand All @@ -316,9 +316,9 @@ module.exports = JhipsterServerGenerator.extend({
message: function (response) {
return getNumberedQuestion('What is the path of your UAA application?.', currentQuestion, totalQuestions, function (current) {
currentQuestion = current;
}, true);
}, applicationType === 'gateway' && response.authenticationType === 'uaa');
},
default: 'uaa'
default: 'jhipsterUAA'
},
{
when: function (response) {
Expand Down Expand Up @@ -685,11 +685,11 @@ module.exports = JhipsterServerGenerator.extend({
}

//this now is job for uaa
if(this.applicationType == 'gateway' && this.authenticationType == 'uaa') {
if(this.applicationType === 'gateway' && this.authenticationType === 'uaa') {
this.skipUserManagement = true;
}

if(applicationType == 'uaa') {
if(applicationType === 'uaa') {
this.authenticationType = 'uaa';
}

Expand Down Expand Up @@ -902,7 +902,7 @@ module.exports = JhipsterServerGenerator.extend({
this.template(DOCKER_DIR + '_elasticsearch.yml', DOCKER_DIR + 'elasticsearch.yml', this, {});
}

if (this.applicationType == 'microservice' || this.applicationType == 'gateway' || this.applicationType == 'uaa') {
if (this.applicationType === 'microservice' || this.applicationType === 'gateway' || this.applicationType === 'uaa') {
this.template(DOCKER_DIR + '_jhipster-registry.yml', DOCKER_DIR + 'jhipster-registry.yml', this, {});
}
this.template(DOCKER_DIR + '_sonar.yml', DOCKER_DIR + 'sonar.yml', this, {});
Expand Down Expand Up @@ -1005,7 +1005,7 @@ module.exports = JhipsterServerGenerator.extend({
/* Skip the code below for --skip-user-management */
if (this.skipUserManagement) return;

if(this.applicationType == 'uaa') {
if(this.applicationType === 'uaa') {
this.template(SERVER_MAIN_SRC_DIR + 'package/config/_UaaWebSecurityConfiguration.java', javaDir + 'config/UaaWebSecurityConfiguration.java', this, {});
this.template(SERVER_MAIN_SRC_DIR + 'package/config/_UaaConfiguration.java', javaDir + 'config/UaaConfiguration.java', this, {});
} else {
Expand All @@ -1022,7 +1022,7 @@ module.exports = JhipsterServerGenerator.extend({
this.template(SERVER_MAIN_SRC_DIR + 'package/security/_UserNotActivatedException.java', javaDir + 'security/UserNotActivatedException.java', this, {});


if (this.authenticationType == 'jwt') {
if (this.authenticationType === 'jwt') {
this.template(SERVER_MAIN_SRC_DIR + 'package/web/rest/dto/_LoginDTO.java', javaDir + 'web/rest/dto/LoginDTO.java', this, {});
this.template(SERVER_MAIN_SRC_DIR + 'package/web/rest/_UserJWTController.java', javaDir + 'web/rest/UserJWTController.java', this, {});
this.template(SERVER_MAIN_SRC_DIR + 'package/web/rest/_JWTToken.java', javaDir + 'web/rest/JWTToken.java', this, {});
Expand Down
Loading

0 comments on commit d7a296f

Please sign in to comment.