diff --git a/package.json b/package.json index 657a952..76ca916 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "@ngneat/overview": "^3.0.0", "@ngneat/until-destroy": "^9.0.0", "firebase": "^9.4.0", + "firebase-functions": "^3.13.1", + "firebase-tools": "^9.4.0", "rxfire": "^6.0.0", "rxjs": "~7.4.0", "tslib": "^2.3.0", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b297a6b..d7f144d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,7 +22,9 @@ import { LandingComponent } from './components/landing/landing.component'; import { MatMenuModule } from '@angular/material/menu'; import { ProfileComponent } from './components/profile/profile.component'; import { getStorage, provideStorage } from '@angular/fire/storage'; - +import { provideAnalytics, getAnalytics, ScreenTrackingService, UserTrackingService } from '@angular/fire/analytics'; +import { FIREBASE_OPTIONS } from '@angular/fire/compat'; +import { AuthService } from './services/auth.service'; @NgModule({ declarations: [ AppComponent, @@ -49,7 +51,11 @@ import { getStorage, provideStorage } from '@angular/fire/storage'; HotToastModule.forRoot(), MatMenuModule, ], - providers: [], + providers: [ + ScreenTrackingService, UserTrackingService, AuthService, + { provide: FIREBASE_OPTIONS, useValue: environment.firebase } + + ], bootstrap: [AppComponent], }) -export class AppModule {} +export class AppModule { } diff --git a/src/app/components/login/login.component.html b/src/app/components/login/login.component.html index 0c94eba..2ad92db 100644 --- a/src/app/components/login/login.component.html +++ b/src/app/components/login/login.component.html @@ -17,8 +17,14 @@

Login

- +
- New to our platform? Sign up! + New to our platform? Sign + up! - + + + + \ No newline at end of file diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index 5a2732e..dfc0c7e 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -16,13 +16,13 @@ export class LoginComponent implements OnInit { }); constructor( - private authService: AuthService, + public authService: AuthService, private toast: HotToastService, private router: Router, private fb: NonNullableFormBuilder - ) {} + ) { } - ngOnInit(): void {} + ngOnInit(): void { } get email() { return this.loginForm.get('email'); diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index 6b9ba07..ff5830e 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -1,15 +1,8 @@ -
+

Update Profile

- + @@ -19,52 +12,27 @@

Update Profile

- + - +
- + - +
- +
-
+
\ No newline at end of file diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 1c3a7cf..e77dfca 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -30,7 +30,7 @@ export class ProfileComponent implements OnInit { private toast: HotToastService, private usersService: UsersService, private fb: NonNullableFormBuilder - ) {} + ) { } ngOnInit(): void { this.usersService.currentUserProfile$ @@ -42,7 +42,7 @@ export class ProfileComponent implements OnInit { uploadFile(event: any, { uid }: ProfileUser) { this.imageUploadService - .uploadImage(event.target.files[0], `images/profile/${uid}`) + .uploadImage(event.target.files[0], `images/profile/users/${uid}`) .pipe( this.toast.observe({ loading: 'Uploading profile image...', diff --git a/src/app/components/sign-up/sign-up.component.html b/src/app/components/sign-up/sign-up.component.html index 0396590..5141275 100644 --- a/src/app/components/sign-up/sign-up.component.html +++ b/src/app/components/sign-up/sign-up.component.html @@ -17,32 +17,27 @@

Sign Up a New User!

- + Password is required - + Confirm Password is required - Passwords should match + Passwords should match
-
+ + + + \ No newline at end of file diff --git a/src/app/components/sign-up/sign-up.component.ts b/src/app/components/sign-up/sign-up.component.ts index e611771..fafef25 100644 --- a/src/app/components/sign-up/sign-up.component.ts +++ b/src/app/components/sign-up/sign-up.component.ts @@ -44,14 +44,14 @@ export class SignUpComponent implements OnInit { ); constructor( - private authService: AuthService, + public authService: AuthService, private router: Router, private toast: HotToastService, private usersService: UsersService, private fb: NonNullableFormBuilder - ) {} + ) { } - ngOnInit(): void {} + ngOnInit(): void { } get email() { return this.signUpForm.get('email'); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 503b8b9..17ba3c2 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -6,9 +6,12 @@ import { createUserWithEmailAndPassword, updateProfile, UserInfo, + signInWithPopup, UserCredential, } from '@angular/fire/auth'; import { concatMap, from, Observable, of, switchMap } from 'rxjs'; +import { GoogleAuthProvider } from 'firebase/auth'; +import firebase from 'firebase/compat'; @Injectable({ providedIn: 'root', @@ -16,7 +19,16 @@ import { concatMap, from, Observable, of, switchMap } from 'rxjs'; export class AuthService { currentUser$ = authState(this.auth); - constructor(private auth: Auth) {} + constructor(private auth: Auth) { } + + // Sign in with Google + GoogleAuth() { + return this.AuthLogin(new GoogleAuthProvider()); + } + // Auth logic to run auth providers + AuthLogin(provider: firebase.auth.AuthProvider | GoogleAuthProvider): Observable { + return from(signInWithPopup(this.auth, provider)); + } signUp(email: string, password: string): Observable { return from(createUserWithEmailAndPassword(this.auth, email, password));