-
Notifications
You must be signed in to change notification settings - Fork 4
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
+509
−10
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 3f08cfc
design: LoginActivty에 필요한 string source 추가
hyunji1203 1697875
feat: 소셜 로그인을 위한 gradle 추가
hyunji1203 bb066d3
feat: 난독화 시 카카오 SDK가 포함되지 않도록 규칙 설정
hyunji1203 d1f7ed0
feat: 카카오 로그인 API key 숨김 처리
hyunji1203 bce127f
feat: 인터넷 사용 권한 허용
hyunji1203 31f7faa
feat: 카카오 로그인 기능을 위한 Redirect URI 설정 추가
hyunji1203 a9e266c
feat: Kakao SDK를 초기화하는 application 구현
hyunji1203 3bd71ee
feat: Kakao 로그인 기능 Util 구현
hyunji1203 fa97311
design: LoginActivity 뷰 구현
hyunji1203 bd35baf
feat: 게임 상태가 진행 중이 아닐 때 Splash 화면에서 로그인 화면으로 이동하도록 구현
hyunji1203 7e59267
feat: 상태바 색상 변경
hyunji1203 cff5507
feat: 로그인 기능 구현
hyunji1203 460efe8
feat: 사용자의 카카오 계정 닉네임을 마이페이지에 보여주는 기능 구현
hyunji1203 4816d66
feat: 서버와 통신해 토큰을 얻어올 때 필요한 Dto, Domain 객체 생성
hyunji1203 5c24439
feat: Dto, Domain 변환 mapper 추가
hyunji1203 a40f690
feat: 서버와 통신하여 로그인 인증을 해주는 retrofit service 구현
hyunji1203 e7f8eaa
feat: 로그인 인증을 통해 토큰을 가져와주는 레포지토리 구현
hyunji1203 faf9967
feat: 서버에게 받은 토큰을 저장하는 SharedPreference 구현
hyunji1203 9bbc81c
feat: 서버에게 토큰을 받아와 로컬 저장소에 저장하는 기능 구현
hyunji1203 a146f29
feat: 카카오 API KEY 감추기에 따른 yml 파일 수정
hyunji1203 6bc2bc0
fix: yml 파일 오류 수정
hyunji1203 23a9bfc
fix: yml 파일 오류 수정
hyunji1203 407b3b5
fix: yml 파일 오류 수정
hyunji1203 2ab0d18
fix: yml 파일 오류 수정
hyunji1203 b19b1f7
refactor: ktlint 적용
hyunji1203 5cc2224
refactor: yml 파일 코드 정리
hyunji1203 18ba7c5
refactor: 암호화 처리 되는 EncryptedSharedPreferences로 변경
hyunji1203 bf96baa
feat: retrofit Header에 서버에서 받아온 토큰 넣어주기 구현
hyunji1203 2d11ffe
refactor: 카카오 토큰을 함수 인자로 받아오도록 수정
hyunji1203 73a59ae
rename: preference가 사용된 파일명을 datasource로 변경
hyunji1203 82a5c97
refactor: 함수 인자명 변경
hyunji1203 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: 사용자의 카카오 계정 닉네임을 마이페이지에 보여주는 기능 구현
commit 460efe8891d7cd77cb052abcd356d1490194aed3
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
_nickname.value = user.kakaoAccount?.profile?.nickname.toString() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = "사용자 정보 요청 성공" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필요하지 않은 로그라면 삭제해볼까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만일 카카오톡에서 사용자 정보를 불러오지 못했을 때 발생할 수 있는 에러에 대해 개발자가 상황을 확인하고 처리할 수 있도록 해당 로그를 넣었습니다.
훗날 파이어베이스 로그를 찍는 로직이 적용된다면 그 땐 지금 위의 로그 로직을 삭제해도 될 것 같아요!