Guest User

Untitled

a guest
Jan 4th, 2019
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. signup(email: string, userName: string, password: string) {
  2. return this.afAuth.auth.createUserWithEmailAndPassword(email, password)
  3. .then((user) => {
  4. this.signupAttempt = 1;
  5. this.authState = user;
  6. const status = 'online';
  7. this.setUserData(email, userName, status);
  8. window.location.reload();
  9. });
  10. }
  11.  
  12. setUserData(email: string, userName: string, status: string) {
  13. const path = `users/${this.currentUserId}`;
  14. const data = {
  15. email: email,
  16. userName: userName,
  17. status: status,
  18. };
  19.  
  20. this.db.object(path).update(data);
  21. }
  22.  
  23. get currentUserId(): string {
  24. if (this.signupAttempt === 1) {
  25. this.signupAttempt = 0;
  26. return this.authState !== null ? this.authState.uid : ' ';
  27. } else {
  28. this.userId = sessionStorage.getItem('userId');
  29. return this.authState !== null ? this.userId : this.authState.uid;
  30. }
  31. }
  32.  
  33. setUserSatus(status: string) {
  34. const path = `users/${this.currentUserId}`;
  35. const data = {
  36. status: status
  37. };
  38. this.db.object(path).update(data);
  39. }
Add Comment
Please, Sign In to add comment