ios - 为什么注销时不解析重置 PFuser?

标签 ios swift parse-platform authentication

我正在使用:

} else if segue.identifier == "logout" {

    var currentUser = PFUser.currentUser()
    PFUser.logOut()
}

单击注销按钮后,它会再次转到登录屏幕,但是如果我单击登录按钮,它会重新登录该用户,而无需再次输入任何凭据。

为什么不在注销时将用户重置为零?

@IBAction func logIn(sender: AnyObject) {

    if username.text == "" || password.text == "" {

       displayNewAlert("Field(s) Empty", message: "Please Enter a Username and Password")

    } else {

        activityIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50))
        activityIndicator.center = self.view.center
        activityIndicator.hidesWhenStopped = true
        activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
        view.addSubview(activityIndicator)
        activityIndicator.startAnimating()
        UIApplication.sharedApplication().beginIgnoringInteractionEvents()


        let user = PFUser()
        user.username = username.text
        user.password = password.text

        var errorMessage = "Please Try Again Later"

        PFUser.logInWithUsernameInBackground(username.text!, password: password.text!, block: { (user, error) -> Void in

            self.activityIndicator.stopAnimating()
            UIApplication.sharedApplication().endIgnoringInteractionEvents()

            if user != nil {

               self.performSegueWithIdentifier("login", sender: self)

            } else {

                if let errorString = error!.userInfo["error"] as? String {

                    errorMessage = errorString

                }

                self.displayNewAlert("Failed Log In", message: "Please enter a valid username and password")
            }
        })
    }
}

最佳答案

我为其他想知道的人解决了这个问题。我正在注销和登录之间做一个 Storyboard 。

我应该使用:

@IBAction func logOut(sender: AnyObject) {

    PFUser.logOut()
let currentUser = PFUser.currentUser()
    self.dismissViewControllerAnimated(true, completion: nil)
}

这是执行注销的正确方法。不是来自上面提到的

    segue.identifier == "....."

关于ios - 为什么注销时不解析重置 PFuser?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33945641/

相关文章:

php - 使用 php 的适用于 iOS 的苹果推送通知和适用于 Android 的谷歌云消息传递?

ios - Facebook 的 invitable_friends 端点导致好友丢失

ios - WKUserNotificationInterfaceController 上的窗框标题是否始终全部大写?

ios - 无法在 IOS 中更改应用程序角标(Badge)

javascript - 发送带有字母数字 "From"的 Twilio SMS 会返回错误消息 'From' 需要电话号码

javascript - 解析 Facebook 登录错误 : "You must initialize FacebookUtils before calling logIn"

ios - 查找距离我当前位置 100 米以内的已保存位置

ios - 如何恢复丢失的 CoreData 模型版本?

objective-c - subscriberCellularProvider 在 iOS 12.0 中被弃用

ios - 在 iOS 应用程序中使用 AWS Cognito 和 Facebook 登录时 IdentityId 为 Nil