Advertisement
Guest User

Untitled

a guest
May 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. registerUser()
  2. {
  3. if (this.newUser.password === this.newUser.passwordConfirm)
  4. {
  5. this.firebaseRef.createUser({email: this.newUser.email, password: this.newUser.password}, (error) => {
  6. if (error) {
  7. console.log(error);
  8. }
  9. });
  10. }
  11. else
  12. {
  13. console.log("Invalid passwords");
  14. }
  15.  
  16. }
  17.  
  18. import { Component, OnInit} from '@angular/core';
  19. import {FirebaseEventPipe} from "../firebasepipe";
  20. import {User} from "../classes/user";
  21.  
  22.  
  23.  
  24. @Component({
  25. selector: 'registration',
  26. templateUrl: 'app/views/registration.component.html',
  27. pipes: [FirebaseEventPipe],
  28.  
  29. })
  30.  
  31. export class RegistrationComponent implements OnInit{
  32.  
  33. private firebaseUrl: string;
  34. private firebaseRef: Firebase;
  35.  
  36. newUser: User;
  37.  
  38. submitted = false;
  39.  
  40. constructor() {
  41. this.firebaseUrl = "https://<<myfirebaseurl>>.firebaseio.com/";
  42. this.firebaseRef = new Firebase(this.firebaseUrl);
  43. }
  44.  
  45. registerUser()
  46. {
  47. if (this.newUser.password === this.newUser.passwordConfirm)
  48. {
  49. this.firebaseRef.createUser({email: this.newUser.email, password: this.newUser.password}, (error) => {
  50. if (error) {
  51. console.log(error);
  52. }
  53. });
  54. }
  55. else
  56. {
  57. console.log("Invalid passwords");
  58. }
  59.  
  60. }
  61.  
  62. ngOnInit():any {
  63. this.newUser = {email: '', password: '', passwordConfirm: ''}
  64. }
  65.  
  66. // TODO: Remove this when we're done
  67. get diagnostic() { return JSON.stringify(this.newUser); }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement