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

[AN] feat: 소셜 로그인 기능 구현 #235

Merged
merged 32 commits into from
Aug 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad222ea
design: LoginActivty에 필요한 drawable source 추가
hyunji1203 Aug 8, 2023
3f08cfc
design: LoginActivty에 필요한 string source 추가
hyunji1203 Aug 8, 2023
1697875
feat: 소셜 로그인을 위한 gradle 추가
hyunji1203 Aug 8, 2023
bb066d3
feat: 난독화 시 카카오 SDK가 포함되지 않도록 규칙 설정
hyunji1203 Aug 8, 2023
d1f7ed0
feat: 카카오 로그인 API key 숨김 처리
hyunji1203 Aug 8, 2023
bce127f
feat: 인터넷 사용 권한 허용
hyunji1203 Aug 8, 2023
31f7faa
feat: 카카오 로그인 기능을 위한 Redirect URI 설정 추가
hyunji1203 Aug 8, 2023
a9e266c
feat: Kakao SDK를 초기화하는 application 구현
hyunji1203 Aug 8, 2023
3bd71ee
feat: Kakao 로그인 기능 Util 구현
hyunji1203 Aug 8, 2023
fa97311
design: LoginActivity 뷰 구현
hyunji1203 Aug 8, 2023
bd35baf
feat: 게임 상태가 진행 중이 아닐 때 Splash 화면에서 로그인 화면으로 이동하도록 구현
hyunji1203 Aug 8, 2023
7e59267
feat: 상태바 색상 변경
hyunji1203 Aug 8, 2023
cff5507
feat: 로그인 기능 구현
hyunji1203 Aug 8, 2023
460efe8
feat: 사용자의 카카오 계정 닉네임을 마이페이지에 보여주는 기능 구현
hyunji1203 Aug 8, 2023
4816d66
feat: 서버와 통신해 토큰을 얻어올 때 필요한 Dto, Domain 객체 생성
hyunji1203 Aug 8, 2023
5c24439
feat: Dto, Domain 변환 mapper 추가
hyunji1203 Aug 8, 2023
a40f690
feat: 서버와 통신하여 로그인 인증을 해주는 retrofit service 구현
hyunji1203 Aug 8, 2023
e7f8eaa
feat: 로그인 인증을 통해 토큰을 가져와주는 레포지토리 구현
hyunji1203 Aug 8, 2023
faf9967
feat: 서버에게 받은 토큰을 저장하는 SharedPreference 구현
hyunji1203 Aug 8, 2023
9bbc81c
feat: 서버에게 토큰을 받아와 로컬 저장소에 저장하는 기능 구현
hyunji1203 Aug 8, 2023
a146f29
feat: 카카오 API KEY 감추기에 따른 yml 파일 수정
hyunji1203 Aug 9, 2023
6bc2bc0
fix: yml 파일 오류 수정
hyunji1203 Aug 9, 2023
23a9bfc
fix: yml 파일 오류 수정
hyunji1203 Aug 9, 2023
407b3b5
fix: yml 파일 오류 수정
hyunji1203 Aug 9, 2023
2ab0d18
fix: yml 파일 오류 수정
hyunji1203 Aug 9, 2023
b19b1f7
refactor: ktlint 적용
hyunji1203 Aug 9, 2023
5cc2224
refactor: yml 파일 코드 정리
hyunji1203 Aug 9, 2023
18ba7c5
refactor: 암호화 처리 되는 EncryptedSharedPreferences로 변경
hyunji1203 Aug 9, 2023
bf96baa
feat: retrofit Header에 서버에서 받아온 토큰 넣어주기 구현
hyunji1203 Aug 9, 2023
2d11ffe
refactor: 카카오 토큰을 함수 인자로 받아오도록 수정
hyunji1203 Aug 9, 2023
73a59ae
rename: preference가 사용된 파일명을 datasource로 변경
hyunji1203 Aug 9, 2023
82a5c97
refactor: 함수 인자명 변경
hyunji1203 Aug 9, 2023
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
Prev Previous commit
Next Next commit
feat: 사용자의 카카오 계정 닉네임을 마이페이지에 보여주는 기능 구현
hyunji1203 committed Aug 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 460efe8891d7cd77cb052abcd356d1490194aed3
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ class MyPageActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic
viewModel.fetchRank()
viewModel.fetchStatistics()
viewModel.fetchPlaces()
viewModel.fetchNickname()
}

private fun subscribe() {
@@ -66,7 +67,9 @@ class MyPageActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic
val placesUiModel = places.map { it.toUiModel() }
binding.customGridMypagePlaces.initContent(placesUiModel)
}

viewModel.nickname.observe(this) { nickname ->
binding.tvMypageNickname.text = nickname
}
viewModel.errorMessage.observe(this) { errorMessage ->
if (NaagaThrowable.ServerConnectFailure().message == errorMessage) {
Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show()
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.now.naaga.presentation.mypage

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.kakao.sdk.user.UserApiClient
import com.now.domain.model.OrderType
import com.now.domain.model.Place
import com.now.domain.model.Rank
@@ -30,6 +32,9 @@ class MyPageViewModel(
private val _errorMessage = MutableLiveData<String>()
val errorMessage: LiveData<String> = _errorMessage

private val _nickname = MutableLiveData<String>()
val nickname: LiveData<String> = _nickname

fun fetchRank() {
rankRepository.getMyRank { result: Result<Rank> ->
result
@@ -54,10 +59,27 @@ class MyPageViewModel(
}
}

fun fetchNickname() {
UserApiClient.instance.me { user, error ->
if (error != null) {
Log.d(KAKAO_USER_INFO_LOG_TAG, KAKAO_USER_INFO_FAIL_MESSAGE + error)
} else if (user != null) {
Log.d(KAKAO_USER_INFO_LOG_TAG, KAKAO_USER_INFO_SUCCESS_MESSAGE)
Comment on lines +64 to +67
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 Author

Choose a reason for hiding this comment

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

만일 카카오톡에서 사용자 정보를 불러오지 못했을 때 발생할 수 있는 에러에 대해 개발자가 상황을 확인하고 처리할 수 있도록 해당 로그를 넣었습니다.
훗날 파이어베이스 로그를 찍는 로직이 적용된다면 그 땐 지금 위의 로그 로직을 삭제해도 될 것 같아요!

_nickname.value = user.kakaoAccount?.profile?.nickname.toString()
Copy link
Collaborator

Choose a reason for hiding this comment

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

위와 마찬가지로 뷰모델 안에서 카카오에 대한 의존성이 발생하는 것 같습니다.
저도 당장 무엇이 가장 좋을지는 잘 모르겠지만
닉네임도 로컬 저장소에 저장했다가 가져오는 방법,
뷰모델이 아닌 액티비티에서 받는 방법 등 여러 방법들이 있을 것 같습니다.

}
}
}

private fun setErrorMessage(throwable: Throwable) {
when (throwable) {
is NaagaThrowable.ServerConnectFailure ->
_errorMessage.value = throwable.message
}
}

companion object {
private const val KAKAO_USER_INFO_LOG_TAG = "kakao user"
private const val KAKAO_USER_INFO_FAIL_MESSAGE = "사용자 정보 요청 실패"
private const val KAKAO_USER_INFO_SUCCESS_MESSAGE = "사용자 정보 요청 성공"
}
}
1 change: 0 additions & 1 deletion android/app/src/main/res/layout/activity_my_page.xml
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@
android:layout_marginStart="@dimen/space_default_large"
android:fontFamily="@font/pretendard_bold"
android:includeFontPadding="false"
android:text="@{viewModel.rank.player.nickname}"
android:textColor="@color/white"
android:textSize="52sp"
android:maxLines="1"