Browse Source

security fix

marinofaggiana 3 years ago
parent
commit
6c57f46e29
1 changed files with 12 additions and 0 deletions
  1. 12 0
      iOSClient/Login/NCLogin.swift

+ 12 - 0
iOSClient/Login/NCLogin.swift

@@ -127,11 +127,14 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         certificate.isEnabled = false
         
         if NCManageDatabase.shared.getAccounts()?.count ?? 0 == 0 {
+            
             imageUser.isHidden = true
             user.isHidden = true
             imagePassword.isHidden = true
             password.isHidden = true
+            
         } else {
+            
             imageUser.isHidden = true
             user.isHidden = true
             imagePassword.isHidden = true
@@ -141,6 +144,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             let navigationItemCancel = UIBarButtonItem.init(barButtonSystemItem: .stop, target: self, action: #selector(self.actionCancel))
             navigationItemCancel.tintColor = textColor
             navigationItem.leftBarButtonItem = navigationItemCancel
+            
+            NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
         }
         
         self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
@@ -158,6 +163,13 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         appDelegate.startTimerErrorNetworking()
     }
     
+    // MARK: - NotificationCenter
+
+    @objc func applicationDidEnterBackground() {
+        
+        dismiss(animated: false)
+    }
+    
     // MARK: - TextField
     
     func textFieldShouldReturn(_ textField: UITextField) -> Bool {