1

I am using swift with parse on xcode and i keep receiving this error:

[Error]: invalid login parameters (Code: 101, Version: 1.7.2)

whenever i try to log in a user i know the user is created in the parse backend and its information is correct. What can i do to stop this from happening and have the user log on without the application sending back invalid login parameters?

here is my 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;
}
}

where am i going wrong in logging in the user?

1 Answers1

5

You pass the strings "email" and "password" to parse and not the actual values of the variables email and password.

Change your code to that:

PFUser.logInWithUsernameInBackground(email, password: password)

Without the ""

Christian
  • 22,585
  • 9
  • 80
  • 106