I have two screens - login & register.
Once a user registers, they will redirect to the login screen. From the login screen once a user enters their login information and password they will be redirected them to home screen.
I want to check whether user has updated their profile data or not. If the user has not updated their profile data, I need to redirect them to the profile screen instead of the home screen.
Here is my code:
@IBAction func loginWithUserNamePassword(){
KRProgressHUD.show(progressHUDStyle: .White, message: "Loading...")
loginWithMailAndPassword((username.text?.trimWhiteSpace)!, password: (password.text?.trimWhiteSpace)!) { (user, error) in
if error != nil{
KRProgressHUD.dismiss()
SCLAlertView().showError("Login Error", subTitle: error!.localizedDescription)
}
else {
KRProgressHUD.dismiss()
if user!.emailVerified{
currentUser = user
enableSync()
self.navigateToNextScreen()
}
else
{
SCLAlertView().showError("Login Error", subTitle: "This email is has not been verified yet")
}
}
}
}
func getAllProfileData(sucessBlock:([String:AnyObject])->Void){
fireBaseRef.child("Users").child(currentUser!.uid).child("UserProfile").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
if let data: [String : AnyObject] = snapshot.value as? [String : AnyObject] {
sucessBlock(data)
}
else{
sucessBlock([:])
}
})
}
func getAllProfiles(sucessBlock:([[String:AnyObject]])->Void){
fireBaseRef.child("Users").observeEventType(.Value, withBlock: { (snapshot) in
var users: [[String: AnyObject]] = []
if let data: [String : AnyObject] = snapshot.value as? [String : AnyObject] {
for (key, value) in data {
if var profile = value["UserProfile"] as? [String : AnyObject] {
profile["UserId"] = key
users.append(profile)
}
}
sucessBlock(users)
}
else{
sucessBlock([[:]])
}
})
}
I haven't used Firebase so far. Any possibility to check whether the user has updated their profile data or not?