Skip to content

Commit

Permalink
fix: authrotiy condition mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
gimhanul committed Sep 16, 2023
1 parent 73332db commit 446d224
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public class StudentController {

@PostMapping
public void joinStudent(
@AuthenticationPrincipal(authority = Authority.USER) User user,
@AuthenticationPrincipal(authority = Authority.STUDENT) User user,
@RequestBody @Valid StudentRequest request
) {
joinStudentService.execute(user, request);
}

@PutMapping
public void updateStudent(
@AuthenticationPrincipal(authority = Authority.USER) User user,
@AuthenticationPrincipal(authority = Authority.STUDENT) User user,
@RequestBody @Valid UpdateStudentRequest request
) {
updateStudentService.execute(user, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m
private void validateAuthority(User user, AuthenticationPrincipal authenticationPrincipal) {
if (
!authenticationPrincipal.authority().equals(Authority.ALL) &&
!user.getAuthority().name().equals(authenticationPrincipal.authority().name())
!user.getAuthority().getRole().equals(authenticationPrincipal.authority().name())
) {
throw AuthorityMismatchException.EXCEPTION;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.soogung.simblue.global.auth.annotation;

public enum Authority {
ALL, USER, TEACHER
ALL, STUDENT, TEACHER
}

0 comments on commit 446d224

Please sign in to comment.