Skip to content

Commit

Permalink
fix: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhouti committed Nov 30, 2023
1 parent c67a930 commit cf250a9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
30 changes: 16 additions & 14 deletions generators/server/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,19 @@ export default class extends ServerGenerator {

/* ************ UserResource.java ************ */
const fileNameUserResource = `${SERVER_MAIN_SRC_DIR}${packageFolder}/web/rest/UserResource.java`;
let resultUserResource = this.fs.read(fileNameUserResource);
resultUserResource = resultUserResource.replace(
'getUserWithAuthoritiesByLogin',
'getUserWithRolesByLogin'
);
this.fs.write(fileNameUserResource, resultUserResource);
if (this.fs.exists(fileNameUserResource)) {
let resultUserResource = this.fs.read(fileNameUserResource);
resultUserResource = resultUserResource.replace(
'getUserWithAuthoritiesByLogin',
'getUserWithRolesByLogin'
);
this.fs.write(fileNameUserResource, resultUserResource);

/* ************ PublicUserResource.java ************ */
const fileNamePublicUserResource = `${SERVER_MAIN_SRC_DIR}${packageFolder}/web/rest/PublicUserResource.java`;
let resultPublicUserResource = this.fs.read(fileNamePublicUserResource);
resultPublicUserResource = resultPublicUserResource.replace(
`
/* ************ PublicUserResource.java ************ */
const fileNamePublicUserResource = `${SERVER_MAIN_SRC_DIR}${packageFolder}/web/rest/PublicUserResource.java`;
let resultPublicUserResource = this.fs.read(fileNamePublicUserResource);
resultPublicUserResource = resultPublicUserResource.replace(
`
/**
* Gets a list of all roles.
Expand All @@ -102,9 +103,10 @@ export default class extends ServerGenerator {
public List<String> getRoles() {
return userService.getRoles();
}`,
''
);
this.fs.write(fileNamePublicUserResource, resultPublicUserResource);
''
);
this.fs.write(fileNamePublicUserResource, resultPublicUserResource);
}

/* ************ PublicUserResourceIT.java ************ */
const fileNamePublicUserResourceIT = `${SERVER_TEST_SRC_DIR}${packageFolder}/web/rest/PublicUserResourceIT.java`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package <%= packageName %>.service.dto;

import <%= packageName %>.security.AuthoritiesConstants;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
Expand All @@ -14,6 +15,7 @@ public class RoleDTO implements Serializable {

private static final long serialVersionUID = 1L;

@NotNull
@Size(max = 50)
@Pattern(regexp = AuthoritiesConstants.ROLE_REGEX)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class RoleResource {
}

/**
* {@code PUT /admin/roles/{nsame}} : Updates an existing Role.
* {@code PUT /admin/roles/{name}} : Updates an existing Role.
*
* @param roleDTO the role to update.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated role.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-jhipster-preauthorize",
"version": "7.9.3",
"version": "7.9.4",
"description": "Preauthorize Blueprint",
"keywords": [
"yeoman-generator",
Expand Down

0 comments on commit cf250a9

Please sign in to comment.