let userEmail = userEmailTextField.text! as String
                  
                  
                          let userPassword = userPasswordTextField.text! as String
                  
                  
                          
                  
                  
                          let parameters = ["auth": ["password": userPassword, "email": userEmail] ]
                  
                  
                          
                  
                  
                          let urlString = "http://localhost:3000/user_token"
                  
                  
                          
                  
                  
                          
                  
                  
                          Alamofire.request(urlString, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: [:])
                  
                  
                              .responseString { response in
                  
                  
                                  print("Success: \(response.result.isSuccess)")
                  
                  
                                  print("Response String: \(response.result.value)")
                  
                  
                                  if let httpError = response.result.error {
                  
                  
                                      _ = httpError.localizedDescription
                  
                  
                                      // show the error message to user
                  
                  
                  
                  
                  
                                  } else { //no errors
                  
                  
                                      if response.result.value == userEmail {
                  
                  
                                      print("Email is invalid/(email)")
                  
                  
                                      } else {
                  
                  
                                      print("Success: \(response.result.isSuccess)")
                  
                  
                                      print("Response String: \(response.result.value)")
                  
                  
                                      let defaults = UserDefaults.standard
                  
                  
                                      defaults.set(true, forKey: "isUserLoggedIn")
                  
                  
                                      defaults.synchronize()
                  
                  
                                  
                  
                  
                                      self.dismiss(animated: true, completion: nil)
                  
                  
                                      let storyboard = UIStoryboard(name: "Main", bundle: nil)
                  
                  
                                      let tabBarController = storyboard.instantiateViewController(withIdentifier: "tabBarController") as! UITabBarController
                  
                  
                                      let appDelelegate = UIApplication.shared.delegate as! AppDelegate
                  
                  
                                      appDelelegate.window?.rootViewController = tabBarController
                  
                  
                                  }
                  
                  
                              }
                  
                  
                          }
                  
                  
                
что в ответе приходит?
Обсуждают сегодня