Skip to content

Commit

Permalink
[PDS-191] feat: 로그인시 fcm 토큰 할당
Browse files Browse the repository at this point in the history
  • Loading branch information
dangnak2 committed Nov 20, 2023
1 parent 386ba59 commit 7cf279e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public class EmailPWReq {
@Pattern(message = "U0003", regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,15}$")
@NotBlank(message = "U0005")
private String password;
@Schema(type = "String", description = "푸쉬 알림 토큰", example = "eAnBcQicRUaSkPCm638VIG...")
private String fcmToken;
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,8 @@ public boolean checkRole(Role role) {
return this.role == role;
}

public void updateFcmToken(String fcmToken) {
this.fcmToken = fcmToken;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public class UserService {
private final EmailUtil emailUtil;

// 로그인
@Transactional
public TokenDto login(EmailPWReq loginReq) {
User user = userRepository.findByEmailAndIsEnable(loginReq.getEmail(), true).orElseThrow(() -> new BaseException(USER_NOT_FOUND));
if(!passwordEncoder.matches(loginReq.getPassword(), user.getPassword())) throw new BaseException(INVALID_PASSWORD);
if (StringUtils.hasText(loginReq.getFcmToken())) user.updateFcmToken(loginReq.getFcmToken());
return jwtUtil.createToken(user.getUserId(), user.getRole());
}

Expand Down

0 comments on commit 7cf279e

Please sign in to comment.