diff --git a/app/src/main/java/com/erica/gamsung/login/data/remote/LoginApi.kt b/app/src/main/java/com/erica/gamsung/login/data/remote/LoginApi.kt
index 3bbec6d..b972484 100644
--- a/app/src/main/java/com/erica/gamsung/login/data/remote/LoginApi.kt
+++ b/app/src/main/java/com/erica/gamsung/login/data/remote/LoginApi.kt
@@ -17,6 +17,6 @@ interface LoginApi {
}
data class TokenResponse(
- val providerId: Long,
+ val id: Long,
val accessToken: String,
)
diff --git a/app/src/main/java/com/erica/gamsung/login/data/repository/LoginRepositoryImpl.kt b/app/src/main/java/com/erica/gamsung/login/data/repository/LoginRepositoryImpl.kt
index 57fb485..d33cec0 100644
--- a/app/src/main/java/com/erica/gamsung/login/data/repository/LoginRepositoryImpl.kt
+++ b/app/src/main/java/com/erica/gamsung/login/data/repository/LoginRepositoryImpl.kt
@@ -3,6 +3,7 @@ package com.erica.gamsung.login.data.repository
import android.content.Context
import android.content.SharedPreferences
import com.erica.gamsung.login.data.remote.LoginApi
+import com.erica.gamsung.login.data.remote.TokenResponse
import com.erica.gamsung.login.domain.LoginRepository
import com.erica.gamsung.menu.data.remote.MenuApi
import com.erica.gamsung.store.data.remote.StoreApi
@@ -19,9 +20,9 @@ class LoginRepositoryImpl(
private val sharedPreferences: SharedPreferences = context.getSharedPreferences("prefs", Context.MODE_PRIVATE)
override suspend fun fetchAccessToken(uuid: String): String {
- val accessToken = loginApi.getToken(uuid).accessToken
- saveToken(accessToken)
- return accessToken
+ val tokenResponse = loginApi.getToken(uuid)
+ saveToken(tokenResponse)
+ return tokenResponse.accessToken
}
override fun getSavedAccessToken(): String? = sharedPreferences.getString("access_token", null)
@@ -40,8 +41,9 @@ class LoginRepositoryImpl(
menuResult.await() && storeResult.await()
}
- private fun saveToken(token: String) {
- sharedPreferences.edit().putString("access_token", token).apply()
+ private fun saveToken(token: TokenResponse) {
+ sharedPreferences.edit().putString("access_token", token.accessToken).apply()
+ sharedPreferences.edit().putLong("memberId", token.id).apply()
}
override fun clearSession() {
@@ -54,4 +56,6 @@ class LoginRepositoryImpl(
loginApi.deleteMember(bearerToken)
}
}
+
+ override fun getMemberId(): Long = sharedPreferences.getLong("memberId", 1L)
}
diff --git a/app/src/main/java/com/erica/gamsung/login/domain/LoginRepository.kt b/app/src/main/java/com/erica/gamsung/login/domain/LoginRepository.kt
index 5b07a11..5aee991 100644
--- a/app/src/main/java/com/erica/gamsung/login/domain/LoginRepository.kt
+++ b/app/src/main/java/com/erica/gamsung/login/domain/LoginRepository.kt
@@ -14,4 +14,6 @@ interface LoginRepository {
fun clearSession()
suspend fun withDraw()
+
+ fun getMemberId(): Long
}
diff --git a/app/src/main/java/com/erica/gamsung/menu/data/repository/FakeMenuRepositoryImpl.kt b/app/src/main/java/com/erica/gamsung/menu/data/repository/FakeMenuRepositoryImpl.kt
index ca6776c..5ea2eeb 100644
--- a/app/src/main/java/com/erica/gamsung/menu/data/repository/FakeMenuRepositoryImpl.kt
+++ b/app/src/main/java/com/erica/gamsung/menu/data/repository/FakeMenuRepositoryImpl.kt
@@ -8,9 +8,12 @@ import kotlinx.coroutines.flow.flowOf
class FakeMenuRepositoryImpl : MenuRepository {
private var db = listOf