-1
我正在自定义解析PFLogInViewController并尝试使其登录按钮将触发查询,以查看用户名是否已存在。如果确实存在,则正常登录将继续。如果它不存在,那么用户将被注册。PFLogInViewController - 只注册并登录登录按钮
我最初在查询的异步性质方面有问题,但我将查询从我的函数中分离出来,这似乎不成问题。正如你在代码中看到的,我已经复制了logInViewController函数,所以它的第二个版本有一个额外的参数doesExist: Bool
。
当我对它进行测试,逻辑上似乎当我在看的打印日志遵循随处可见,但复制的logInViewController功能不实际登录用户英寸
感谢任何意见!
func signUpFunc(username: String, password: String) {
//this is the sign up function
print(username)
print(password)
print("this is the sign up function")
}
func doesUserExist(username: String, password: String) {
var query = PFUser.query()
query!.whereKey("username", equalTo: username)
query?.findObjectsInBackgroundWithBlock({ (users, error) -> Void in
if let users = users {
if users.count == 0 {
self.signUpFunc(username, password: password)
} else {
print ("made it here")
print(username)
print(password)
let testController = LoginViewController()
self.logInViewController(true, logInController: testController, shouldBeginLogInWithUsername: username, password: password)
}
}
})
}
func logInViewController(logInController: PFLogInViewController, shouldBeginLogInWithUsername username: String, password: String) -> Bool {
//this function happens on the initial click of the login button
self.doesUserExist(username, password: password)
return false
}
func logInViewController(doesExist: Bool, logInController: PFLogInViewController, shouldBeginLogInWithUsername username: String, password: String) -> Bool {
//this should actually log the user in or give error if user/pass combo is wrong
print("made it to login")
print(username)
print(password)
return true
}
我实际上没有看到任何地方,你叫'loginWithUsernameInBackground:密码:block' – Paulw11
嗨@ Paulw11我实际上并不在任何地方调用它。当使用PFLogInViewController时,我认为按下登录按钮时内置了一些功能,但我无法在任何地方看到它。我可以在文档中找到的唯一功能是logInViewController(.... shouldBeginLogInWithUsername ....)。我会尝试调用loginWithUsernameInBackground来处理登录端,看看它是否工作。谢谢! –
您正在用您自己的视图控制器替换'PFLoginViewController'的功能,因此只需忽略该类并直接使用'PFUser'上可用的方法 – Paulw11