Skip to content

Commit f6806d8

Browse files
authored
Merge pull request #57 from TAMULib/sprint5-b03527-b03528-tab-access-and-order
Expanded role enum and altered controller access
2 parents f965930 + 1e02749 commit f6806d8

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/main/java/edu/tamu/app/controller/NoteController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ public ApiResponse getById(@PathVariable Long id) {
4141
}
4242

4343
@RequestMapping("/create")
44-
@PreAuthorize("hasRole('SERVICE_MANAGER')")
44+
@PreAuthorize("hasRole('WEB_MANAGER')")
4545
@WeaverValidation(business = { @WeaverValidation.Business(value = CREATE) })
4646
public ApiResponse create(@WeaverValidatedModel Note note, @WeaverCredentials Credentials credentials) throws UserNotFoundException {
4747
return new ApiResponse(SUCCESS, noteRepo.create(note, credentials));
4848
}
4949

5050
@RequestMapping("/update")
51-
@PreAuthorize("hasRole('SERVICE_MANAGER')")
51+
@PreAuthorize("hasRole('WEB_MANAGER')")
5252
public ApiResponse update(@WeaverValidatedModel Note note) {
5353
return new ApiResponse(SUCCESS, noteRepo.update(note));
5454
}
5555

5656
@Transactional
5757
@RequestMapping("/remove")
58-
@PreAuthorize("hasRole('SERVICE_MANAGER')")
58+
@PreAuthorize("hasRole('WEB_MANAGER')")
5959
public ApiResponse remove(@WeaverValidatedModel Note note) {
6060
noteRepo.delete(note);
6161
return new ApiResponse(SUCCESS);

src/main/java/edu/tamu/app/controller/NotificationController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ public ApiResponse getById(@PathVariable Long id) {
4040
}
4141

4242
@RequestMapping("/create")
43-
@PreAuthorize("hasRole('WEB_MANAGER')")
43+
@PreAuthorize("hasAnyRole('ADMIN','SERVICE_ADMIN','NOTICE_MANAGER')")
4444
@WeaverValidation(business = { @WeaverValidation.Business(value = CREATE) })
4545
public ApiResponse create(@WeaverValidatedModel Notification notification) {
4646
return new ApiResponse(SUCCESS, notificationRepo.create(notification));
4747
}
4848

4949
@RequestMapping("/update")
50-
@PreAuthorize("hasRole('WEB_MANAGER')")
50+
@PreAuthorize("hasAnyRole('ADMIN','SERVICE_ADMIN','NOTICE_MANAGER')")
5151
@WeaverValidation(business = { @WeaverValidation.Business(value = UPDATE) })
5252
public ApiResponse update(@WeaverValidatedModel Notification notification) {
5353
return new ApiResponse(SUCCESS, notificationRepo.update(notification));
5454
}
5555

5656
@RequestMapping("/remove")
57-
@PreAuthorize("hasRole('WEB_MANAGER')")
57+
@PreAuthorize("hasAnyRole('ADMIN','SERVICE_ADMIN','NOTICE_MANAGER')")
5858
@WeaverValidation(business = { @WeaverValidation.Business(value = DELETE) })
5959
public ApiResponse remove(@WeaverValidatedModel Notification notification) {
6060
notificationRepo.delete(notification);

src/main/java/edu/tamu/app/controller/UserController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public ApiResponse getUser(@WeaverUser User user) {
7878
* @throws Exception
7979
*/
8080
@RequestMapping
81-
@PreAuthorize("hasRole('WEB_MANAGER')")
81+
@PreAuthorize("hasRole('ADMIN')")
8282
public ApiResponse allUsers() throws Exception {
8383
return new ApiResponse(SUCCESS, userRepo.findAll());
8484
}
@@ -90,7 +90,7 @@ public ApiResponse allUsers() throws Exception {
9090
* @throws Exception
9191
*/
9292
@RequestMapping("/update")
93-
@PreAuthorize("hasRole('WEB_MANAGER')")
93+
@PreAuthorize("hasRole('ADMIN')")
9494
public ApiResponse updateUser(@RequestBody User user) throws Exception {
9595
user = userRepo.save(user);
9696
simpMessagingTemplate.convertAndSend("/channel/user", new ApiResponse(SUCCESS, userRepo.findAll()));

src/main/java/edu/tamu/app/enums/Role.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
public enum Role implements IRole {
66

7-
ROLE_ADMIN, ROLE_WEB_MANAGER, ROLE_SERVICE_MANAGER, ROLE_STAFF, ROLE_USER, ROLE_ANONYMOUS
7+
ROLE_ADMIN, ROLE_SERVICE_ADMIN, ROLE_SERVICE_MANAGER, ROLE_WEB_MANAGER, ROLE_NOTICE_MANAGER, ROLE_STAFF, ROLE_USER, ROLE_ANONYMOUS
88

99
}

0 commit comments

Comments
 (0)