Skip to content

Commit

Permalink
[REFACTOR] #141 : SignUpRepository, SignUpDataSource -> AuthRepositor…
Browse files Browse the repository at this point in the history
…y, AuthDataSource로 병합
  • Loading branch information
tgyuuAn committed Mar 3, 2024
1 parent dc71e79 commit 8b54e72
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import com.wap.wapp.core.data.repository.attendancestatus.AttendanceStatusReposi
import com.wap.wapp.core.data.repository.attendancestatus.AttendanceStatusRepositoryImpl
import com.wap.wapp.core.data.repository.auth.AuthRepository
import com.wap.wapp.core.data.repository.auth.AuthRepositoryImpl
import com.wap.wapp.core.data.repository.auth.SignUpRepository
import com.wap.wapp.core.data.repository.auth.SignUpRepositoryImpl
import com.wap.wapp.core.data.repository.event.EventRepository
import com.wap.wapp.core.data.repository.event.EventRepositoryImpl
import com.wap.wapp.core.data.repository.management.ManagementRepository
Expand Down Expand Up @@ -74,10 +72,4 @@ abstract class DataModule {
abstract fun bindsAttendanceStatusRepository(
attendanceStatusRepositoryImpl: AttendanceStatusRepositoryImpl,
): AttendanceStatusRepository

@Binds
@Singleton
abstract fun bindsSignUpRepository(
signUpRepositoryImpl: SignUpRepositoryImpl,
): SignUpRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ interface AuthRepository {
suspend fun deleteUser(): Result<Unit>

suspend fun isUserSignIn(): Result<Boolean>

suspend fun validationWapCode(code: String): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ class AuthRepositoryImpl @Inject constructor(
override suspend fun deleteUser(): Result<Unit> = authDataSource.deleteUser()

override suspend fun isUserSignIn(): Result<Boolean> = authDataSource.isUserSignIn()

override suspend fun validationWapCode(code: String): Result<Boolean> =
authDataSource.validationWapCode(code)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wap.wapp.core.domain.usecase.auth

import com.wap.wapp.core.data.repository.auth.SignUpRepository
import com.wap.wapp.core.domain.model.CodeValidation
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import com.wap.wapp.core.network.source.attendancestatus.AttendanceStatusDataSou
import com.wap.wapp.core.network.source.attendancestatus.AttendanceStatusDataSourceImpl
import com.wap.wapp.core.network.source.auth.AuthDataSource
import com.wap.wapp.core.network.source.auth.AuthDataSourceImpl
import com.wap.wapp.core.network.source.auth.SignUpDataSource
import com.wap.wapp.core.network.source.auth.SignUpDataSourceImpl
import com.wap.wapp.core.network.source.event.EventDataSource
import com.wap.wapp.core.network.source.event.EventDataSourceImpl
import com.wap.wapp.core.network.source.management.ManagementDataSource
Expand Down Expand Up @@ -75,10 +73,4 @@ abstract class NetworkModule {
abstract fun bindsAttendanceStatusDataSource(
attendanceStatueDataSourceImpl: AttendanceStatusDataSourceImpl,
): AttendanceStatusDataSource

@Binds
@Singleton
abstract fun bindsSignUpDataSource(
signUpDataSourceImpl: SignUpDataSourceImpl,
): SignUpDataSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ interface AuthDataSource {
suspend fun deleteUser(): Result<Unit>

suspend fun isUserSignIn(): Result<Boolean>

suspend fun validationWapCode(code: String): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package com.wap.wapp.core.network.source.auth

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseAuth.AuthStateListener
import com.google.firebase.firestore.FirebaseFirestore
import com.wap.wapp.core.network.constant.CODES_COLLECTION
import com.wap.wapp.core.network.utils.await
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
import javax.inject.Inject

class AuthDataSourceImpl @Inject constructor(
private val firebaseAuth: FirebaseAuth,
private val firebaseFirestore: FirebaseFirestore,
) : AuthDataSource {
override suspend fun signOut(): Result<Unit> = runCatching {
firebaseAuth.signOut()
Expand Down Expand Up @@ -45,4 +48,13 @@ class AuthDataSourceImpl @Inject constructor(
}
}
}

override suspend fun validationWapCode(code: String): Result<Boolean> = runCatching {
val result = firebaseFirestore.collection(CODES_COLLECTION)
.whereEqualTo("user", code)
.get()
.await()

result.isEmpty.not()
}
}

This file was deleted.

This file was deleted.

0 comments on commit 8b54e72

Please sign in to comment.