Skip to content

Commit

Permalink
fix : 회원가입 실패 케이스 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Aug 3, 2024
1 parent 3d35e8e commit 3b1a75b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sealed interface LoginEvent {
data object RequireSignUp : LoginEvent
data object SignOutCancelled : LoginEvent
data object Invalid : LoginEvent
data object SignupFailed : LoginEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.nexters.boolti.presentation.component.BTDialog
import com.nexters.boolti.presentation.component.BtCloseableAppBar
import com.nexters.boolti.presentation.component.KakaoLoginButton
import com.nexters.boolti.presentation.component.MainButton
import com.nexters.boolti.presentation.screen.LocalSnackbarController
import com.nexters.boolti.presentation.theme.Grey30
import com.nexters.boolti.presentation.theme.marginHorizontal

Expand All @@ -49,18 +50,22 @@ fun LoginScreen(
modifier: Modifier = Modifier,
viewModel: LoginViewModel = hiltViewModel(),
) {
val context = LocalContext.current
val snackbarController = LocalSnackbarController.current

val sheetState = rememberModalBottomSheetState()
var showSignOutCancelledDialog by remember { mutableStateOf(false) }
var isSheetOpen by rememberSaveable { mutableStateOf(false) }
val loginFailedMessage = stringResource(id = R.string.login_failed)
val signupFailedMessage = stringResource(id = R.string.signup_failed)

LaunchedEffect(Unit) {
viewModel.event.collect {
when (it) {
LoginEvent.Success -> onBackPressed()
LoginEvent.RequireSignUp -> isSheetOpen = true
LoginEvent.SignOutCancelled -> showSignOutCancelledDialog = true
LoginEvent.Invalid -> Toast.makeText(context, "로그인 실패", Toast.LENGTH_SHORT).show()
LoginEvent.Invalid -> snackbarController.showMessage(loginFailedMessage)
LoginEvent.SignupFailed -> snackbarController.showMessage(signupFailedMessage)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.nexters.boolti.presentation.screen.login

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.nexters.boolti.domain.repository.AuthRepository
import com.nexters.boolti.domain.request.LoginRequest
import com.nexters.boolti.domain.request.OauthType
Expand Down Expand Up @@ -39,7 +40,7 @@ class LoginViewModel @Inject constructor(
else -> event(LoginEvent.Success)
}
}.onFailure {
Timber.d("login failed: $it")
FirebaseCrashlytics.getInstance().setCustomKey("LOGIN", "FAILED")
event(LoginEvent.Invalid)
}
}
Expand Down Expand Up @@ -78,7 +79,8 @@ class LoginViewModel @Inject constructor(
).onSuccess {
event(LoginEvent.Success)
}.onFailure {
// TODO 예외 처리
FirebaseCrashlytics.getInstance().setCustomKey("SIGNUP", "FAILED")
event(LoginEvent.SignupFailed)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
<string name="nickname_default">불티 유저</string>
<string name="signout_cancelled_message">30일 내에 로그인하여\n계정 삭제가 취소되었어요.\n불티를 다시 찾아주셔서 감사해요!</string>
<string name="user_code">식별 코드</string>
<string name="login_failed">로그인 실패</string>
<string name="signup_failed">회원가입 실패</string>

<!-- 탈퇴 -->
<string name="signout">계정 삭제</string>
Expand Down

0 comments on commit 3b1a75b

Please sign in to comment.