Advertisement
Guest User

Untitled

a guest
May 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. //
  2. // Created by Charly Maxter on 14/2/18.
  3. // Copyright © 2018 Flashy. All rights reserved.
  4. //
  5.  
  6. import UIKit
  7. import Firebase
  8.  
  9. class vcRegistro: UIViewController {
  10.  
  11. @IBOutlet var tfEmail: UITextField!
  12. @IBOutlet var tfPass: UITextField!
  13.  
  14. override func viewDidLoad() {
  15. super.viewDidLoad()
  16.  
  17.  
  18. }
  19.  
  20. override func didReceiveMemoryWarning() {
  21. super.didReceiveMemoryWarning()
  22.  
  23. }
  24.  
  25.  
  26. @IBAction func registro(){
  27. registroF(email: tfEmail.text!, pass: tfPass.text!)
  28. }
  29.  
  30. @IBAction func login(){
  31. loginF(email: tfEmail.text!, pass: tfPass.text!)
  32. }
  33.  
  34.  
  35. func registroF(email:String, pass:String){
  36. Auth.auth().createUser(withEmail: email, password: pass) { (user, error) in
  37. if error == nil {
  38. //Dataholder.sharedInstance.firDataBaseRef.child("Usuarios").child((user?.uid)!).setValue("HOLA")
  39. print("REGISTRADO!")
  40. self.avanzar()
  41. }else{
  42. print(error)
  43. }
  44. }
  45. }
  46.  
  47. func loginF(email: String, pass: String){
  48. Auth.auth().signIn(withEmail: email, password: pass) { (user, error) in
  49. if error == nil {
  50. self.avanzar()
  51. } else {
  52. //TODO NOTIFICAR ERROR
  53. }
  54. }
  55. }
  56.  
  57. func avanzar(){
  58. performSegue(withIdentifier: "seguePrinci", sender: self)
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement