瀏覽代碼

Implemented Validate password API on Account screen so that it can logout if password is changed

Khubaib 8 月之前
父節點
當前提交
9153946d13

+ 2 - 2
.idea/deploymentTargetSelector.xml

@@ -4,10 +4,10 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-09-06T11:28:15.931591121Z">
+        <DropdownSelection timestamp="2024-09-10T14:40:56.666833887Z">
           <Target type="DEFAULT_BOOT">
             <handle>
-              <DeviceId pluginId="LocalEmulator" identifier="path=/home/ubuntu/.android/avd/Television_1080p_API_31.avd" />
+              <DeviceId pluginId="PhysicalDevice" identifier="serial=1C051FDF60048Z" />
             </handle>
           </Target>
         </DropdownSelection>

+ 23 - 0
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/AccountScreen.kt

@@ -95,6 +95,29 @@ fun Account(navHostController: NavHostController,
     val context = LocalContext.current
     val basePreferenceHelper = BasePreferenceHelper(context)
     val accountViewModel: AccountViewModel = viewModel()
+    val scope = rememberCoroutineScope()
+    val homeViewModel: HomeViewModel = viewModel{ HomeViewModel(context, scope) }
+
+    LaunchedEffect(key1 = Unit) {
+        homeViewModel.validatePassword(
+            basePreferenceHelper.getUser()?.userinfo?.email.toString(),
+            basePreferenceHelper.getPassword().toString(),
+            "android",
+            android.os.Build.VERSION.RELEASE
+        )
+    }
+
+    val validateResponse = homeViewModel.liveDataValidate.observeAsState().value
+    validateResponse?.let {
+        if (!it.status) {
+            basePreferenceHelper.setLoggedInState(false)
+            basePreferenceHelper.clearAllData()
+            settingsNavHostController.popBackStack()
+            settingsNavHostController.navigate(Screen.Started.route)
+        }
+
+        homeViewModel._mutableLiveDataValidate.value = null
+    }
 
     CompositionLocalProvider(
         LocalOverscrollConfiguration provides null