Skip to content

Commit

Permalink
Merge pull request #17 from PawWithU/feature/login
Browse files Browse the repository at this point in the history
feature/login: 로그인 UI 구현, 소셜 로그인 기능 구현
  • Loading branch information
kang9366 authored Nov 9, 2023
2 parents 9f19b46 + ae31dbc commit 73a04cf
Show file tree
Hide file tree
Showing 542 changed files with 1,567 additions and 355 deletions.
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,26 @@
.externalNativeBuild
.cxx
local.properties
.idea/
.idea/
core/designsystem/build/intermediates/
core/model/build/intermediates
core/designsystem/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/
core/model/build/intermediates/incremental/
core/designsystem/build/.transforms/
core/model/build/.transforms/
core/designsystem/build/tmp/kotlin-classes/debug/com/kusitms/connectdog/core/designsystem/component/
core/model/build/tmp/
core/designsystem/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/
core/model/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/
core/model/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/
core/model/build/kotlin/compileDebugKotlin/local-state/
core/designsystem/build/kotlin/compileDebugKotlin/local-state/
core/model/build/intermediates/manifest_merge_blame_file/debug/
core/designsystem/build/outputs/logs/
core/model/build/outputs/logs/
core/designsystem/build/tmp/kotlin-classes/debug/com/kusitms/connectdog/core/designsystem/theme/
core/model/build/kotlin/compileDebugKotlin/cacheable/
core/designsystem/build/kotlin/compileDebugKotlin/cacheable/
core/designsystem/build/outputs/aar/
core/model/build/outputs/aar/
core/designsystem/build/tmp/kotlin-classes/debug/META-INF
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ android {
dependencies {
implementation(project(":feature:main"))
implementation(project(":feature:home"))
implementation(project(":feature:login"))

implementation(libs.androidx.core.splashscreen)

Expand All @@ -62,6 +63,7 @@ dependencies {
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation(libs.kakao.oauth)
}

kapt {
Expand Down
26 changes: 23 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,37 @@
android:supportsRtl="true"
android:theme="@style/Theme.ConnectDog"
tools:targetApi="33">
<meta-data
android:name="com.kakao.sdk.AppKey"
android:value="@string/kakao_app_key" />

<activity android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="oauth"
android:scheme="kakao227799f94d3661c7d84b79daba3b0eaa" />
</intent-filter>
</activity>

<activity
android:name=".feature.main.MainActivity"
android:name=".feature.login.LoginActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.ConnectDog.Splash">
android:theme="@style/Theme.ConnectDog.Splash"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".feature.main.MainActivity"
android:exported="true">
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.kusitms.connectdog

import android.app.Application
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class ConnectDogApplication : Application()
class ConnectDogApplication : Application() {
override fun onCreate() {
super.onCreate()
KakaoSdk.init(this, "227799f94d3661c7d84b79daba3b0eaa")
}
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ object Configuration {
const val minorVersion = 0
const val patchVersion = 0
const val versionName = "$majorVersion.$minorVersion.$patchVersion"
}
}
3 changes: 3 additions & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ dependencies {
implementation(libs.okhttp.logging)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.datetime)

implementation(libs.naver.oauth)
implementation(libs.kakao.oauth)
}

kapt {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
package com.kusitms.connectdog.core.data.di

import android.content.Context
import com.kusitms.connectdog.core.data.repository.DefaultExampleRepository
import com.kusitms.connectdog.core.data.repository.ExampleRepository
import com.kusitms.connectdog.core.data.repository.LoginRepository
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent

@InstallIn(SingletonComponent::class)
@Module
internal abstract class DataModule {
@Binds
abstract fun bindsExampleRepository(repository: DefaultExampleRepository): ExampleRepository

companion object {
@Provides
fun provideLoginRepository(
@ApplicationContext context: Context
): LoginRepository {
return LoginRepository(context)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.kusitms.connectdog.core.data.repository

import android.content.Context
import android.util.Log
import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.common.KakaoSdk
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient
import com.navercorp.nid.NaverIdLoginSDK
import com.navercorp.nid.oauth.NidOAuthLogin
import com.navercorp.nid.oauth.OAuthLoginCallback
import com.navercorp.nid.profile.NidProfileCallback
import com.navercorp.nid.profile.data.NidProfileResponse
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class LoginRepository
@Inject
constructor(
@ApplicationContext private val context: Context
) {
fun initNaverLogin(activity: Context) {
NaverIdLoginSDK.initialize(activity, "rWBuAHxm0vihdivNGAZI", "8Sfw75g883", "connectdog")
NaverIdLoginSDK.authenticate(activity, naverLoginCallback)
}

private val naverLoginCallback =
object : OAuthLoginCallback {
override fun onSuccess() {
NidOAuthLogin().callProfileApi(
object : NidProfileCallback<NidProfileResponse> {
override fun onSuccess(result: NidProfileResponse) {
val userName = result.profile!!.name.toString()
val userEmail = result.profile!!.email.toString()
val userNickname = result.profile!!.nickname.toString()
val userImage = result.profile!!.profileImage

Log.d("naver login data", NaverIdLoginSDK.getAccessToken().toString())
Log.d("naver login data", NaverIdLoginSDK.getExpiresAt().toString())
Log.d("naver login data", userName)
Log.d("naver login data", userEmail)
Log.d("naver login data", userNickname)
Log.d("naver login data", userImage.toString())
}

override fun onError(
errorCode: Int,
message: String
) {
Log.e("login", message)
}

override fun onFailure(
httpStatus: Int,
message: String
) {
Log.e("login", message)
}
}
)
}

override fun onError(
errorCode: Int,
message: String
) {
// TODO("Not yet implemented")
}

override fun onFailure(
httpStatus: Int,
message: String
) {
// TODO("Not yet implemented")
}
}

fun initKakaoLogin(context: Context) {
KakaoSdk.init(context, "227799f94d3661c7d84b79daba3b0eaa")

val kakaoLoginCallback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
if (error != null) {
Log.e("Kakao Login", "카카오계정으로 로그인 실패", error)
} else if (token != null) {
Log.i("Kakao Login", "카카오계정으로 로그인 성공 ${token.accessToken}")
UserApiClient.instance.me { user, error ->
if (error != null) {
Log.e("Kakao Login", "사용자 정보 요청 실패", error)
} else if (user != null) {
}
}
}
}

// 카카오톡이 설치되어 있으면 카카오톡으로 로그인, 아니면 카카오계정으로 로그인
if (UserApiClient.instance.isKakaoTalkLoginAvailable(context)) {
UserApiClient.instance.loginWithKakaoTalk(context) { token, error ->
if (error != null) {
Log.e("Kakao Login", "카카오톡으로 로그인 실패", error)

if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
return@loginWithKakaoTalk
}

UserApiClient.instance.loginWithKakaoAccount(context, callback = kakaoLoginCallback)
} else if (token != null) {
Log.i("Kakao Login", "카카오 로그인 성공 ${token.accessToken}")
UserApiClient.instance.me { user, error ->
if (error != null) {
Log.e("Kakao Login", "사용자 정보 요청 실패", error)
} else if (user != null) {
}
}
}
}
} else {
UserApiClient.instance.loginWithKakaoAccount(context, callback = kakaoLoginCallback)
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Empty file.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

0 comments on commit 73a04cf

Please sign in to comment.