Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions src/main/java/land/leets/domain/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ public User getUser(String idToken) throws GeneralSecurityException, IOException
return bySub.get();
}

User user = User.builder()
.sub(userId)
.name((String) payload.get("name"))
.email(payload.getEmail())
.build();
User user = new User(
null,
(String) payload.get("name"),
null,
payload.getEmail(),
userId,
null
);

return userRepository.save(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public AuthDetails loadUserByUsername(String email) throws UsernameNotFoundExcep
User user = this.userRepository
.findByEmail(email)
.orElseThrow(() -> new UsernameNotFoundException(ErrorCode.USER_NOT_FOUND.getMessage()));
return new AuthDetails(user.getUid(), user.getEmail(), AuthRole.ROLE_USER);
return new AuthDetails(user.getId(), user.getEmail(), AuthRole.ROLE_USER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class AuthController {
@GetMapping("/login/oauth2/callback/google")
public JwtResponse get(@RequestParam("code") String code) throws GeneralSecurityException, IOException {
User user = authService.getGoogleToken(code);
String accessToken = this.jwtProvider.generateToken(user.getUid(), user.getEmail(), AuthRole.ROLE_USER, false);
String refreshToken = this.jwtProvider.generateToken(user.getUid(), user.getEmail(), AuthRole.ROLE_USER, true);
String accessToken = this.jwtProvider.generateToken(user.getId(), user.getEmail(), AuthRole.ROLE_USER, false);
String refreshToken = this.jwtProvider.generateToken(user.getId(), user.getEmail(), AuthRole.ROLE_USER, true);

return new JwtResponse(accessToken, refreshToken);
}
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/land/leets/domain/user/domain/User.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/land/leets/domain/user/usecase/UpdateUser.java

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/land/leets/domain/user/usecase/UpdateUserImpl.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/land/leets/global/jwt/JwtProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String generateToken(UUID uuid, String sub, AuthRole role, boolean isRefr

return Jwts.builder()
.claim("role", role.getRole())
.claim(role == AuthRole.ROLE_USER ? "uid" : "id", uuid.toString())
.claim("id" , uuid.toString())
.subject(sub)
.expiration(isRefreshToken ? Date.from(refreshDate) : Date.from(accessDate))
.signWith(isRefreshToken ? refreshSecret : accessSecret)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AdminRefreshTokenImpl(
jwtProvider.validateToken(refreshToken, true)
val claims = jwtProvider.parseClaims(refreshToken, true)
val role = claims.get("role", String::class.java)
val uuid = UUID.fromString(claims.get("uid", String::class.java))
val uuid = UUID.fromString(claims.get("id", String::class.java))
val newAccessToken = jwtProvider.generateToken(uuid, claims.subject, AuthRole.valueOf(role), false)
return JwtResponse(newAccessToken, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.time.LocalDateTime
@Entity(name = "applications")
class Application(
@OneToOne
@JoinColumn(name = "uid")
@JoinColumn(name = "id")
var user: User,

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateApplicationImpl(
override fun execute(authDetails: AuthDetails, request: ApplicationRequest): Application {
val user: User = userRepository.findById(authDetails.uid).orElseThrow { UserNotFoundException() }

if (applicationRepository.findByUser_Uid(user.getUid()) != null) {
if (applicationRepository.findByUser_Uid(user.id!!) != null) {
throw ApplicationAlreadyExistsException()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetAllApplicationImpl(
private fun mapApplications(applications: List<Application>): List<ApplicationResponse> {
return applications.map { application ->
val interview = getInterview.execute(application)
val phone = application.user.getPhone()
val phone = application.user.phone ?: ""
ApplicationResponse.of(application, interview, phone)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GetApplicationDetailsImpl(

private fun getDetails(application: Application): ApplicationDetailsResponse {
val interview = getInterviewDetails.execute(application)
val phone = application.user.getPhone()
val phone = application.user.phone ?: ""
return ApplicationDetailsResponse.of(application, interview, phone)
}
}
Loading