Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Apr 6, 2024
2 parents 3576a88 + fef353c commit f151fb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/main/java/unithon/uniletter/login/dto/LoginRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ public record LoginRequest(
String email
) {

public Optional<String> getName() {
return Optional.ofNullable(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import unithon.uniletter.member.Member;
import unithon.uniletter.member.repository.MemberRepository;

import java.util.Optional;
import java.util.UUID;

@Service
Expand All @@ -21,20 +20,20 @@ public class LoginService {
public String createToken(final LoginRequest loginRequest) {
final String memberIdentifier = jwtProvider.decodeSub(loginRequest.token(), loginRequest.email());
final Member registeredMember = memberRepository.findByIdentifier(memberIdentifier)
.orElseGet(() -> registerMember(memberIdentifier, loginRequest.email(), loginRequest.getName()));
.orElseGet(() -> registerMember(memberIdentifier, loginRequest.email(), loginRequest.name()));
final UUID id = registeredMember.getId();
return jwtProvider.createAccessTokenWith(id);
}

private Member registerMember(final String memberAppleIdentifier, final String email, final Optional<String> name) {
private Member registerMember(final String memberAppleIdentifier, final String email, final String name) {
final String nickname = parseEmail(email);
final String validateNickname = generateValidateNickname(nickname);
final String memberName = name.orElse(validateNickname);
final String validatedName = (name.equals("")) ? validateNickname : name;

final Member member = Member.builder()
.nickname(validateNickname)
.identifier(memberAppleIdentifier)
.name(memberName)
.name(validatedName)
.build();

return memberRepository.save(member);
Expand Down

0 comments on commit f151fb8

Please sign in to comment.