Skip to content

Commit

Permalink
[Feat/#122] 카카오 토큰 삭제 기능 추가 (#123)
Browse files Browse the repository at this point in the history
* [Feat/#122] 카카오 토큰 삭제 기능 추가

* [Fix/#122] 액세스 토큰 없을 때 자동 로그인 확인용 boolean값 추가
  • Loading branch information
yeoncheong authored Sep 8, 2023
1 parent b9361c0 commit d95a34f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ class LoginActivity : BindingActivity<ActivityLoginBinding>(R.layout.activity_lo
// 온보딩 x 연결 o -> 초대받는 측
else if (response.username == null) {
Log.d("LoginActivity", "온보딩 x 연결 o")
SharedPreferences.setInviteCodeBoolean(DID_USER_CLEAR_INVITE_CODE, true)
goInputInfoActivity()
}
// 온보딩 o -> 연결 여부와 관계 없이 main으로 이동임
else {
Log.d("LoginActivity", "온보딩 o")
SharedPreferences.setOnboardingBoolean(DID_USER_CLEAR_ONBOARD, true)
SharedPreferences.setOnboardingBoolean(DID_USER_CLEAR_INVITE_CODE, true)
goMainActivity()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.viewModels
import com.kakao.sdk.user.UserApiClient
import com.ubcompany.umbba_android.data.local.SharedPreferences
import com.ubcompany.umbba_android.databinding.FragemntDeleteAccountDialogBinding
import com.ubcompany.umbba_android.presentation.login.LoginActivity
Expand Down Expand Up @@ -57,13 +59,24 @@ class DeleteAccountDialogFragment : DialogFragment() {
viewModel.responseStatus.observe(this) {
if (it == 200) {
SharedPreferences.clearForSignout()
unlinkForKakao()
val intent = Intent(requireActivity(), LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
}
}
}

private fun unlinkForKakao() {
UserApiClient.instance.unlink { error ->
if (error != null) {
Log.e("Unlink for Kakao", "연결 끊기 실패", error)
} else {
Log.d("Unlink for Kakao", "연결 끊기 성공")
}
}
}

override fun onResume() {
super.onResume()
dialog?.window?.setLayout(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.ubcompany.umbba_android.presentation.setting

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.viewModels
import com.kakao.sdk.user.UserApiClient
import com.ubcompany.umbba_android.R
import com.ubcompany.umbba_android.data.local.SharedPreferences
import com.ubcompany.umbba_android.databinding.ActivityManageAccountBinding
Expand Down Expand Up @@ -34,13 +36,24 @@ class ManageAccountActivity :
viewModel.responseStatus.observe(this@ManageAccountActivity) {
if (it == 200) {
SharedPreferences.clearForLogout()
logoutForKakao()
val intent = Intent(this, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
}
}
}

private fun logoutForKakao() {
UserApiClient.instance.logout { error ->
if (error != null) {
Log.e("logout for Kakao", "로그아웃 실패, 토큰 삭제", error)
} else {
Log.d("logout for Kakao", "로그아웃 성공, 토큰 삭제")
}
}
}

private fun setClickEvent() {
with(binding) {
clLogout.setOnSingleClickListener {
Expand Down

0 comments on commit d95a34f

Please sign in to comment.