Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- signup(email: string, userName: string, password: string) {
- return this.afAuth.auth.createUserWithEmailAndPassword(email, password)
- .then((user) => {
- this.signupAttempt = 1;
- this.authState = user;
- const status = 'online';
- this.setUserData(email, userName, status);
- window.location.reload();
- });
- }
- setUserData(email: string, userName: string, status: string) {
- const path = `users/${this.currentUserId}`;
- const data = {
- email: email,
- userName: userName,
- status: status,
- };
- this.db.object(path).update(data);
- }
- get currentUserId(): string {
- if (this.signupAttempt === 1) {
- this.signupAttempt = 0;
- return this.authState !== null ? this.authState.uid : ' ';
- } else {
- this.userId = sessionStorage.getItem('userId');
- return this.authState !== null ? this.userId : this.authState.uid;
- }
- }
- setUserSatus(status: string) {
- const path = `users/${this.currentUserId}`;
- const data = {
- status: status
- };
- this.db.object(path).update(data);
- }
Add Comment
Please, Sign In to add comment