我有一个应用程序(用Swift编写)使用Parse并允许用户创建一个帐户。我希望用户可以选择删除他们的帐户,但似乎无法弄清楚,不知道我在做什么错误。我希望用户必须验证他们的电子邮件和密码才会发生。一旦他们删除了他们的账户,就会弹出一个警告,然后一旦用户解除了警报,就会将他们带回登录屏幕并退出应用程序。删除解析PFUser帐户
这是我已经试过:
@IBAction func deleteAccount(sender: AnyObject) {
if PFUser.currentUser()?.username == emailAddressTextField.text && PFUser.currentUser()?.password == passwordTextFieldOne.text && PFUser.currentUser()?.password == passwordTextFieldTwo.text {
PFUser.currentUser()?.deleteInBackgroundWithBlock({ (success: Bool, error: NSError?) -> Void in
if success {
let alertController = UIAlertController(title: "Success!", message: "Now Please Login", preferredStyle: .Alert)
let enterAppAction = UIAlertAction(title: "OK", style: .Default, handler: { (UIAlertAction) -> Void in
dispatch_async(dispatch_get_main_queue(), {() -> Void in
let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("Login")
self.presentViewController(viewController, animated: true, completion: nil)
})
})
alertController.addAction(enterAppAction)
self.presentViewController(alertController, animated: true, completion: nil)
} else {
print(error)
self.displayAlert("Account deletion failed", message: "Please try again", actionTitle: "OK")
}
})
}
}
你得到一个错误? –
不,我认为这不是读取PFUser.currentUser密码,因为当我打印出来它打印零。这是有道理的,因为Parse保护他们的密码。我只是让它工作,以便用户可以删除他们的计数,但它不需要任何电子邮件或密码验证。他们只是点击一个按钮,它删除了帐户。我宁愿有验证。 – dcotter
你可以尝试做一些像query.wherekey(电子邮件= PFUser.currentUser()。电子邮件)和之后做一个删除?我不记得query.wherekey的correcxt语法.. –