Skip to content

Commit

Permalink
Merge pull request #213 from PLADI-ALM/feat/PDS-191-fcm-login
Browse files Browse the repository at this point in the history
[PDS-191/feat] 로그인시 fcm 토큰 할당
  • Loading branch information
chaerlo127 authored Nov 20, 2023
2 parents 7c7798e + 7cf279e commit daaac88
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 daaac88

Please sign in to comment.