Skip to content

Commit

Permalink
[FEAT/#100] 토큰 재발급 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
gaeun5744 committed Oct 15, 2023
1 parent 4a18115 commit 651e6bb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import com.puzzling.puzzlingaos.data.model.request.RequestLoginDto
import com.puzzling.puzzlingaos.data.model.response.ResponseLoginDto
import com.puzzling.puzzlingaos.data.model.response.ResponseTokenDto
import com.puzzling.puzzlingaos.data.service.AuthService
import com.puzzling.puzzlingaos.data.service.ReIssueTokenService
import javax.inject.Inject

class AuthDataSourceImpl @Inject constructor(private val apiService: AuthService) : AuthDataSource {
class AuthDataSourceImpl @Inject constructor(
private val authService: AuthService,
private val reIssueTokenService: ReIssueTokenService,
) : AuthDataSource {

override suspend fun login(socialPlatform: String): ResponseLoginDto =
apiService.login(RequestLoginDto(socialPlatform))
authService.login(RequestLoginDto(socialPlatform))

override suspend fun getToken(): ResponseTokenDto = apiService.getToken()
override suspend fun getToken(): ResponseTokenDto =
reIssueTokenService.getToken()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.puzzling.puzzlingaos.data.repository

import android.util.Log
import androidx.datastore.core.DataStore
import com.puzzling.puzzlingaos.data.datasource.local.UserDataSource
import com.puzzling.puzzlingaos.data.datasource.remote.AuthDataSource
import com.puzzling.puzzlingaos.data.entity.Token
import com.puzzling.puzzlingaos.data.entity.User
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/puzzling/puzzlingaos/di/ApiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.puzzling.puzzlingaos.data.service.AuthService
import com.puzzling.puzzlingaos.data.service.MyPageService
import com.puzzling.puzzlingaos.data.service.PersonalReviewService
import com.puzzling.puzzlingaos.data.service.ProjectService
import com.puzzling.puzzlingaos.data.service.ReIssueTokenService
import com.puzzling.puzzlingaos.data.service.TeamReviewService
import com.puzzling.puzzlingaos.data.service.WriteReviewService
import dagger.Module
Expand Down Expand Up @@ -45,4 +46,9 @@ object ApiModule {
@Singleton
fun provideAuthService(@PuzzlingRetrofit retrofit: Retrofit): AuthService =
retrofit.create(AuthService::class.java)

@Provides
@Singleton
fun provideReIssueTokenService(@ReIssueRetrofit retrofit: Retrofit): ReIssueTokenService =
retrofit.create(ReIssueTokenService::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.puzzling.puzzlingaos.presentation.onboarding

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -39,6 +40,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
finish()
viewModel.getToken()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class LoginViewModel @Inject constructor(
}.handleResult(token, error)
}

init {
getToken()
}

fun login(socialPlatform: String) = viewModelScope.launch {
Log.d("LoginActivity", "로그인 함수 호출")
authRepository.login("KAKAO")
Expand Down

0 comments on commit 651e6bb

Please sign in to comment.