-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat/#58] auth
- Loading branch information
Showing
10 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
data/src/main/java/com/kkkk/data/dto/request/AuthRequestDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.kkkk.data.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class AuthRequestDto( | ||
@SerialName("deviceTag") | ||
val deviceTag: String, | ||
@SerialName("password") | ||
val password: String | ||
) |
25 changes: 19 additions & 6 deletions
25
data/src/main/java/com/kkkk/data/repositoryImpl/AuthRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
package com.kkkk.data.repositoryImpl | ||
|
||
import com.kkkk.data.dataSource.AuthDataSource | ||
import com.kkkk.data.dto.request.AuthRequestDto | ||
import com.kkkk.domain.entity.response.AuthTokenModel | ||
import com.kkkk.domain.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl | ||
@Inject | ||
constructor( | ||
class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource, | ||
) : AuthRepository { | ||
override suspend fun reissueTokens( | ||
authorization: String | ||
authorization: String, | ||
): Result<AuthTokenModel> = runCatching { | ||
authDataSource.postReissueTokens( | ||
authorization, | ||
).data.toModel() | ||
} | ||
|
||
override suspend fun login( | ||
deviceTag: String | ||
deviceTag: String, | ||
): Result<AuthTokenModel> = runCatching { | ||
authDataSource.postLogin(deviceTag).data.toModel() | ||
authDataSource.postLogin( | ||
AuthRequestDto( | ||
deviceTag = deviceTag, | ||
password = "" | ||
) | ||
).data.toModel() | ||
} | ||
|
||
override suspend fun signup(deviceTag: String): Result<AuthTokenModel> = runCatching { | ||
authDataSource.postSignUp( | ||
AuthRequestDto( | ||
deviceTag = deviceTag, | ||
password = "" | ||
) | ||
).data.toModel() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
package com.kkkk.data.service | ||
|
||
import com.kkkk.data.dto.BaseResponse | ||
import com.kkkk.data.dto.request.AuthRequestDto | ||
import com.kkkk.data.dto.request.TokenRequestDto | ||
import com.kkkk.data.dto.response.AuthTokenDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.Header | ||
import retrofit2.http.POST | ||
|
||
interface AuthService { | ||
@POST("api/v1/reissue") | ||
@POST("api/v1/auth/reissue") | ||
suspend fun postReissueTokens( | ||
@Header("Authorization") authorization: String | ||
): BaseResponse<AuthTokenDto> | ||
|
||
@POST("api/v1/login") | ||
@POST("api/v1/auth/login") | ||
suspend fun postLogin( | ||
@Header("Authorization") deviceTag: String, | ||
@Body auth: AuthRequestDto, | ||
): BaseResponse<AuthTokenDto> | ||
|
||
@POST("api/v1/auth/register") | ||
suspend fun postSignUp( | ||
@Body auth: AuthRequestDto, | ||
): BaseResponse<AuthTokenDto> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters