Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MyPage/aos] 로그아웃, 회원 탈퇴 후 화면 전환 #117

Merged
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
6 changes: 6 additions & 0 deletions Aos/app/src/main/java/com/avengers/nibobnebob/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class App : Application(){

init {
instance = this
}

override fun onCreate() {
super.onCreate()
initializeNaverSDK()
}

companion object{
lateinit var instance : App
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = APP_NAME)
fun getContext(): Context = instance.applicationContext
}

private fun initializeNaverSDK(){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.avengers.nibobnebob.config

import android.util.Log
import com.avengers.nibobnebob.app.DataStoreManager
import com.avengers.nibobnebob.presentation.util.Constants.ACCESS
import com.avengers.nibobnebob.presentation.util.Constants.AUTHORIZATION
import com.avengers.nibobnebob.presentation.util.Constants.BEARER
import kotlinx.coroutines.flow.first
Expand All @@ -18,11 +16,10 @@ class AccessTokenInterceptor @Inject constructor(private val dataStoreManager: D
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {

// 동기가 아닌 비동기로 불러와야한다.. runBlocking말고 다른 방안에 대해 고민
val accessToken = runBlocking {
dataStoreManager.getAccessToken().first()
}
Log.d("토큰 테스트",accessToken.toString())

val builder: Request.Builder = chain.request().newBuilder()
accessToken?.takeIf { it.isNotEmpty() }?.let {
builder.addHeader(AUTHORIZATION, "$BEARER $it")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.avengers.nibobnebob.config


import android.content.Intent
import com.avengers.nibobnebob.app.App
import com.avengers.nibobnebob.app.DataStoreManager
import com.avengers.nibobnebob.data.model.BaseState
import com.avengers.nibobnebob.data.model.request.RefreshTokenRequest
import com.avengers.nibobnebob.data.model.response.BaseResponse
import com.avengers.nibobnebob.data.model.response.NaverLoginResponse
import com.avengers.nibobnebob.data.model.runRemote
import com.avengers.nibobnebob.data.remote.RefreshApi
import com.avengers.nibobnebob.presentation.ui.intro.IntroActivity
import com.avengers.nibobnebob.presentation.util.Constants
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -48,11 +51,15 @@ class BearerInterceptor @Inject constructor(
else -> {
dataStoreManager.deleteAccessToken()
dataStoreManager.deleteRefreshToken()

val intent = Intent(App.getContext(), IntroActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
App.getContext().startActivity(intent)
}
}
}
}
(newAccessToken)?.let {
newAccessToken?.let {
val newRequest = originalRequest.newBuilder()
.addHeader(AUTHORIZATION, "$BEARER $newAccessToken")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.avengers.nibobnebob.data.model.response.MyDefaultInfoResponse
import com.avengers.nibobnebob.data.model.response.MyInfoResponse
import com.avengers.nibobnebob.data.model.runRemote
import com.avengers.nibobnebob.data.remote.MyPageApi
import com.navercorp.nid.oauth.NidOAuthLogin
import com.navercorp.nid.oauth.OAuthLoginCallback
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject
Expand Down Expand Up @@ -43,6 +45,15 @@ class MyPageRepositoryImpl @Inject constructor(
is BaseState.Success -> {
dataStoreManager.deleteAccessToken()
dataStoreManager.deleteRefreshToken()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 autoLogin도 지우는게 나을 것 같아!

NidOAuthLogin().callDeleteTokenApi(object : OAuthLoginCallback{
override fun onError(errorCode: Int, message: String) {}

override fun onFailure(httpStatus: Int, message: String) {}

override fun onSuccess() {}
})

emit(result)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_
viewModel.events.collect { event ->
when (event) {
is MyEditPageEvent.NavigateToIntro -> {
(activity as MainActivity).finish()
val intent = Intent(context, IntroActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

startActivity(intent)
}
}
Expand All @@ -76,7 +76,6 @@ class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_
}

private fun withDrawConfirm() {
Log.d("TEST", "탈퇴 완료")
viewModel.withdraw()
}

Expand Down