Guest User

Untitled

a guest
Feb 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. if(usernameTaken) {
  2.  
  3.  
  4. }else{
  5. /*Username is available - Check email taken or not (if not, register)*/
  6. var error = self.firebaseProvider.registerUser(self.email,self.password,self.username, self.name);
  7.  
  8. if(error.code !== ""){
  9. if(error.code == "auth/email-already-in-use"){
  10. let alert = self.alertCtrl.create({
  11. title: 'Email Exists',
  12. subTitle: 'The email you entered is already registered.',
  13. buttons: ['Retry']
  14. });
  15. alert.present();
  16. }else if(error.code == 'auth/weak-password') {
  17. let alert = self.alertCtrl.create({
  18. title: 'Validation Error',
  19. subTitle: 'The password entered is weak and should be 6 characters.',
  20. buttons: ['Retry']
  21. });
  22. alert.present();
  23. }
  24. }
  25. }
  26.  
  27. registerUser(email: string, password: string, username: string, name: string): (any) {
  28. var self = this;
  29.  
  30. this.fbAuth.auth.createUserWithEmailAndPassword(email, password).then(function() {
  31. var user = firebase.auth().currentUser;
  32. self.createUserRecord(username, email, name);
  33. }).catch(function(error) {
  34. //Handle error
  35. return error;
  36. });
  37.  
  38. }
Add Comment
Please, Sign In to add comment