Right, i've been through the Firebase IOS Swift documentation and still cant find the answer i'm looking for.
In my SignUp ViewController:
if let userName = self.userName.text where userName != "", let email = self.email.text where email != "", let password = self.password.text where password != "" {
DataService.dataService.BASE_REF.createUser(email, password: password, withValueCompletionBlock: { error, result in
if error != nil {
print(error)
} else {
// CREATE AND LOGIN THE NEW USER WITH AUTHUSER
DataService.dataService.BASE_REF.authUser(email, password: password, withCompletionBlock: { error, authData in
let user = ["provider": authData.provider!, "email": email, "username": userName]
DataService.dataService.createNewAccount(authData.uid, user: user)
})
NSUserDefaults.standardUserDefaults().setValue(result ["uid"], forKey: "uid")
//PERFORM SEGUE TO LOG USER IN
self.signUP.animate(1, completion: {
let myTabbarController = self.storyboard?.instantiateViewControllerWithIdentifier("myTabbarController") as! UITabBarController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = myTabbarController
myTabbarController.transitioningDelegate = self
})
}
})
} else{
self.showErrorAlert("All fields are required", msg: "Please sign up")
}
}
When user imput email such as a@a.com, the console accepts. I though the server side would handle this. Similarly, when i generate a code to handle this issue such as :
// FUNC TO VALIDATE EMAIL ADDRESS
func isValidEmail(testStr:String) -> Bool {
// println("validate calendar: \(testStr)")
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluateWithObject(testStr)
}
It still accepts false emails so long as it has the at "@" symbol with a ".com"
How can i validate user email is accurate such as a@google.com
, etc? ...