From f8eaa53c9b981139f5a380d630dd52388cadb680 Mon Sep 17 00:00:00 2001 From: mjkwahk Date: Tue, 10 Dec 2024 16:52:25 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95=20(#2?= =?UTF-8?q?95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/mhnfe/ui/screens/auth/login/LoginViewModel.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt b/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt index 16cb7a78..52e4586b 100644 --- a/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt +++ b/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt @@ -98,11 +98,16 @@ class LoginViewModel @Inject constructor( _errorMessage.value = "네트워크 오류가 발생했습니다. 인터넷 연결을 확인해주세요." } catch (e: HttpException) { when (e.code()) { - 400, 404 -> { + 400 -> { _errorMessage.value = "잘못된 아이디 또는 비밀번호입니다." Log.e("LoginViewModel", "Error: ${_errorMessage.value}") } + 404 -> { + _errorMessage.value = "회원 정보를 찾을 수 없습니다." + Log.e("LoginViewModel", "Error: ${_errorMessage.value}") + } + else -> { Log.e("LoginViewModel", "HttpException: ${e.message}") _errorMessage.value = "서버 오류가 발생했습니다. 다시 시도해주세요." From 224d0b61ccaf067e62490ba22eb299e8ebeafc31 Mon Sep 17 00:00:00 2001 From: mjkwahk Date: Tue, 10 Dec 2024 18:05:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EC=9E=84=EC=8B=9C=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EB=B2=88=ED=98=B8=20=EC=A0=84=EC=86=A1=EC=8B=9C=20Toa?= =?UTF-8?q?st=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80=20(#295)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/mhnfe/ui/screens/auth/login/LoginViewModel.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt b/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt index 52e4586b..54b54842 100644 --- a/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt +++ b/app/src/main/java/com/example/mhnfe/ui/screens/auth/login/LoginViewModel.kt @@ -1,7 +1,9 @@ package com.example.mhnfe.ui.screens.auth.login +import android.content.Context import android.content.SharedPreferences import android.util.Log +import android.widget.Toast import androidx.datastore.core.DataStore import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -14,6 +16,7 @@ import com.example.mhnfe.data.remote.response.RefreshToken import com.example.mhnfe.data.remote.response.SendPasswordResponse import com.example.mhnfe.data.repository.AuthRepository import dagger.hilt.android.lifecycle.HiltViewModel +import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.first @@ -30,7 +33,8 @@ class LoginViewModel @Inject constructor( private val refreshTokenDataStore: DataStore, private val groupIdDataStore: DataStore, private val memberIdDataStore: DataStore, - private val sharedPreferences: SharedPreferences + private val sharedPreferences: SharedPreferences, + @ApplicationContext private val context: Context ) : ViewModel() { // 로그인 결과 상태 @@ -187,6 +191,7 @@ class LoginViewModel @Inject constructor( if(response.result.code == 200) { _sendPasswordResponse.value = response _errorMessage.value = null + Toast.makeText(context, "임시 비밀번호가 메일로 전송되었습니다.", Toast.LENGTH_SHORT).show() } else { _errorMessage.value = mapErrorMessage( response.result.code,