Skip to content

Commit

Permalink
chore: ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
huglx committed Nov 12, 2024
1 parent de625ec commit 6426f6f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PublicController(
private val userCredentialsService: UserCredentialsService,
private val authProperties: AuthenticationProperties,
@Lazy
private val authProviderChangeRequestService: AuthProviderChangeRequestService
private val authProviderChangeRequestService: AuthProviderChangeRequestService,
) {
@Operation(summary = "Generate JWT token")
@PostMapping("/generatetoken")
Expand Down Expand Up @@ -270,9 +270,8 @@ class PublicController(
@GetMapping("/auth-provider/get-request")
fun getAuthProviderChangeRequest(
@RequestParam("requestId") id: Long,
): AuthProviderChangeResponseDto {
return AuthProviderChangeResponseDto.fromEntity(authProviderChangeRequestService.getById(id))
}
): AuthProviderChangeResponseDto =
AuthProviderChangeResponseDto.fromEntity(authProviderChangeRequestService.getById(id))

private fun getFakeGithubUser(): UserAccount {
val username = "johndoe@doe.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class OAuthUserHandler(
private fun manageUserNameConflict(
user: UserAccount,
userResponse: OAuthUserDetails,
thirdPartyAuthType: ThirdPartyAuthType
thirdPartyAuthType: ThirdPartyAuthType,
) {
userConflictManager.manageUserNameConflict(
user,
Expand All @@ -114,7 +114,7 @@ class OAuthUserHandler(
userResponse.tenant?.domain,
userResponse.sub,
userResponse.refreshToken,
calculateExpirationDate()
calculateExpirationDate(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ class UserConflictManager(
ssoDomain: String? = null,
sub: String? = null,
refreshToken: String? = null,
calculateExpirationDate: Date? = null
calculateExpirationDate: Date? = null,
) {

val requestData = AuthProviderChangeRequestData(
userAccount = user,
newAuthProvider = newAuthProvider,
oldAuthProvider = user.thirdPartyAuthType,
newAccountType = newAccountType,
oldAccountType = user.accountType,
ssoDomain = ssoDomain,
sub = sub,
refreshToken = refreshToken,
calculateExpirationDate = calculateExpirationDate
)
val requestData =
AuthProviderChangeRequestData(
userAccount = user,
newAuthProvider = newAuthProvider,
oldAuthProvider = user.thirdPartyAuthType,
newAccountType = newAccountType,
oldAccountType = user.accountType,
ssoDomain = ssoDomain,
sub = sub,
refreshToken = refreshToken,
calculateExpirationDate = calculateExpirationDate,
)
val request = authProviderChangeRequestService.create(requestData)
throw AuthenticationException(Message.USERNAME_ALREADY_EXISTS, listOf(request?.id))
}

fun resolveRequestIfExist(user: Optional<UserAccount>) {
if(user.isPresent) {
if (user.isPresent) {
authProviderChangeRequestService.resolveChangeRequestIfExist(user.get())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package io.tolgee.development.testDataBuilder.data
import io.tolgee.development.testDataBuilder.builders.TestDataBuilder
import io.tolgee.model.UserAccount

class ChangeAuthTypeTestData: BaseTestData() {

class ChangeAuthTypeTestData : BaseTestData() {
var userExisting: UserAccount

val createUserExisting: TestDataBuilder =
TestDataBuilder().apply {
userExisting = addUserAccount {
name = "fake_email@email.com"
username = "fake_email@email.com"
}.self
userExisting =
addUserAccount {
name = "fake_email@email.com"
username = "fake_email@email.com"
}.self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ data class AuthProviderChangeRequestData(
val ssoDomain: String? = null,
val sub: String? = null,
val refreshToken: String? = null,
val calculateExpirationDate: Date? = null
val calculateExpirationDate: Date? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package io.tolgee.dtos.request

data class AuthProviderChangeRequestDto(
val isConfirmed: Boolean,
val changeRequestId: Long
val changeRequestId: Long,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ package io.tolgee.dtos.response

import io.tolgee.model.AuthProviderChangeRequest

data class AuthProviderChangeResponseDto (
data class AuthProviderChangeResponseDto(
var newAuthType: String?,
var oldAuthType: String?,
var newAccountType: String?,
var userId: Long?,
var oldAccountType: String?
var oldAccountType: String?,
) {
companion object {
fun fromEntity(entity: AuthProviderChangeRequest): AuthProviderChangeResponseDto {
return AuthProviderChangeResponseDto(
fun fromEntity(entity: AuthProviderChangeRequest): AuthProviderChangeResponseDto =
AuthProviderChangeResponseDto(
newAuthType = entity.newAuthProvider?.code(),
oldAuthType = entity.oldAuthProvider?.code(),
newAccountType = entity.newAccountType?.name,
userId = entity.userAccount?.id,
oldAccountType = entity.userAccount?.accountType?.name
oldAccountType = entity.userAccount?.accountType?.name,
)
}
}

}

0 comments on commit 6426f6f

Please sign in to comment.