每次我尝试在登录页面上登录用户时,我都会收到无效的登录参数

Dan*_*bek 1 xcode login parse-platform swift

我在xcode上使用swift和解析,我一直收到这个错误:

[Error]: invalid login parameters (Code: 101, Version: 1.7.2)
Run Code Online (Sandbox Code Playgroud)

每当我尝试登录用户时,我知道用户是在解析后端创建的,并且其信息是正确的.我该怎么做才能阻止这种情况发生并让用户在没有应用程序发回无效登录参数的情况下登录?

这是我的LogInViewController:

import Foundation
import Parse
import UIKit
import Bolts

class LoginViewController: UIViewController, UITextFieldDelegate {


@IBOutlet weak var loginStatusLabel: UILabel!

@IBOutlet weak var emailTextField: UITextField!


@IBOutlet weak var passwordTextField: UITextField!


@IBOutlet weak var loginButton: UIButton!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    emailTextField.delegate = self
    passwordTextField.delegate = self
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
@IBAction func loginButtonPress(sender: AnyObject) {

    login(emailTextField.text, password: passwordTextField.text)
}


func login(email: String, password: String)
{

    PFUser.logInWithUsernameInBackground("email", password: "password")
        {
        (user: PFUser?, error: NSError?) -> Void in
            if user != nil
            {
                user!.fetch()
                if user!.objectForKey("emailVerified") as! Bool
                {
                    self.loginStatusLabel.text = "Success!"
                }
                else if !(user!.objectForKey("emailVerified") as! Bool)
                {
                    self.loginStatusLabel.text = "Verify your email address!"
                }
                else // status is "missing"
                {
                    //TODO: Handle this error better
                    self.loginStatusLabel.text = "Verification status: Missing"
                }

            }
            else
            {
                if let errorField = error!.userInfo
                {
                    self.loginStatusLabel.text = (errorField["error"] as! NSString) as String
                }
                else
                {
                    // No userInfo dictionary present
                    // Help from http://stackoverflow.com/questions/25381338/nsobject-anyobject-does-not-have-a-member-named-subscript-error-in-xcode
                }

            }
    }
}

func textFieldShouldReturn(textField: UITextField) -> Bool {
    textField.resignFirstResponder()
    return true;
}
}
Run Code Online (Sandbox Code Playgroud)

我在登录用户时出错了?

Chr*_*örz 5

您通过串"email""password"分析和不变量的实际值emailpassword.

将您的代码更改为:

PFUser.logInWithUsernameInBackground(email, password: password)
Run Code Online (Sandbox Code Playgroud)

没有 ""