0

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?

Jordi Bruin
  • 1,588
  • 1
  • 11
  • 20
hybrid Dev
  • 529
  • 3
  • 14
  • 33
  • 2
    Possible duplicate of [Swift & Firebase | Checking if a user exists with a username](http://stackoverflow.com/questions/36442114/swift-firebase-checking-if-a-user-exists-with-a-username) – Sasha Kozachuk Dec 05 '16 at 08:57
  • i already saw that, but i dont know how can i handle in my project – hybrid Dev Dec 05 '16 at 09:01

0 Answers0