Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class AuthService {
private final ApplicationEventPublisher eventPublisher;
private final NotificationUserClient notificationUserClient;
private final FilterRepository filterRepository;
private static final String TOKEN_PREFIX = "Bearer ";


@Transactional
public SignInResponse signIn(String socialAccessToken, SignInRequest request) {
Expand All @@ -61,11 +63,16 @@ public SignInResponse signIn(String socialAccessToken, SignInRequest request) {

@Transactional
public SignUpResponse signUp(String authId, SignUpRequest request) {
if (userRepository.existsByAuthIdAndAuthType(authId, request.authType())) {
String resolvedAuthId = authId;
if (resolvedAuthId != null && resolvedAuthId.startsWith(TOKEN_PREFIX)) {
resolvedAuthId = resolvedAuthId.substring(TOKEN_PREFIX.length());
}

if (userRepository.existsByAuthIdAndAuthType(resolvedAuthId, request.authType())) {
throw new AuthException(AuthErrorCode.USER_ALREADY_EXIST);
}

User userToSave = User.from(authId, request);
User userToSave = User.from(resolvedAuthId, request);
userRepository.save(userToSave);

Token token = jwtProvider.generateTokens(userToSave.getId());
Expand Down
Loading