Skip to content

Commit

Permalink
feat: 멤버 인증에 guest 추가 및 두피 케어 기기 접근 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Dec 14, 2023
1 parent 9fae8f6 commit de14b29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public class MemberAuthNames {

public static final String ROLE_MEMBER = "ROLE_MEMBER";

public static final String ROLE_GUEST = "ROLE_GUEST";

public static String combine(String... names) {
return String.join(",", names);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.taba.nimonaemo.global.auth.role;

import com.taba.nimonaemo.global.auth.jwt.AppAuthentication;
import lombok.Getter;

import java.util.Map;
Expand All @@ -11,6 +12,7 @@
@Getter
public enum MemberRole {
MEMBER(ROLE_MEMBER),
GUEST(ROLE_GUEST),
ADMIN(combine(ROLE_ADMIN, ROLE_MEMBER));

private final String name;
Expand All @@ -26,12 +28,12 @@ public static MemberRole of(String name) {
return BY_LABEL.get(name);
}

// public static MemberRole from(AppAuthentication auth) {
// if (auth == null) {
// return GUEST;
// }
// return auth.getMemberRole();
// }
public static MemberRole from(AppAuthentication auth) {
if (auth == null) {
return GUEST;
}
return auth.getUserRole();
}

public boolean isAdmin() {
return this == ADMIN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.taba.nimonaemo.product.controller;

import com.taba.nimonaemo.global.auth.jwt.AppAuthentication;
import com.taba.nimonaemo.global.auth.role.AdminAuth;
import com.taba.nimonaemo.product.exception.ProductNotFoundException;
import com.taba.nimonaemo.product.model.dto.request.RequestInputCareDeviceDto;
import com.taba.nimonaemo.product.model.dto.request.RequestProductDto;
Expand Down Expand Up @@ -50,7 +52,8 @@ public List<ResponseProductDto> careDevice() {
* @param dto 요청 body
*/
@PostMapping("/input")
public void inputCareDevice(@Valid @RequestBody RequestInputCareDeviceDto dto) {
@AdminAuth
public void inputCareDevice(AppAuthentication auth, @Valid @RequestBody RequestInputCareDeviceDto dto) {
scalpCareProductService.addCareDevice(dto);
}
}

0 comments on commit de14b29

Please sign in to comment.