Last active
September 18, 2019 15:01
-
-
Save xErik/9dbc8329863cfa9cd4d0b2e94e34aff9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g @angular/cli | |
ng new new-project | |
cd new-project | |
npm install firebase @angular/fire bootstrap jquery --save | |
# Set DB: Firestore | |
# Set public directory: dist/new-project | |
firebase init | |
# firebase deploy should trigger a production build. | |
# add to package.json: | |
# | |
# "scripts": { "build": "ng build --configuration=production"} | |
# Copy firebase config into environment/environment.ts and environment/environment.prod.ts | |
#export const environment = { | |
# production: false, | |
# firebaseConfig: { | |
# ... | |
# } | |
#}; | |
# Add stuff to src/app/module.ts | |
# import { AngularFireModule } from "@angular/fire"; | |
# import { AngularFireAuthModule } from "@angular/fire/auth"; | |
# import { environment } from '../environments/environment'; | |
# import { AuthenticationService } from './shared/authentication.service'; | |
# | |
# @NgModule({ | |
# declarations: [...], | |
# imports: [ | |
# AngularFireAuthModule, | |
# AngularFireModule.initializeApp(environment.firebaseConfig), | |
# ], | |
# providers: [AuthenticationService], | |
# bootstrap: [...], | |
# schemas: [...] | |
# }) | |
# Generate authentication: | |
ng g s shared/Authentication --spec=false | |
# Store in src/app/shared/authentication.service.ts: | |
# | |
# import { Injectable } from '@angular/core'; | |
# import { AngularFireAuth } from "@angular/fire/auth"; | |
# import { Observable } from 'rxjs'; | |
# @Injectable({ | |
# providedIn: 'root' | |
# }) | |
# export class AuthenticationService { | |
# userData: Observable<firebase.User>; | |
# constructor(private angularFireAuth: AngularFireAuth) { | |
# this.userData = angularFireAuth.authState; | |
# } | |
# SignUp(email: string, password: string) { | |
# this.angularFireAuth | |
# .auth | |
# .createUserWithEmailAndPassword(email, password) | |
# .then(res => { | |
# console.log('Successfully signed up!', res); | |
# }) | |
# .catch(error => { | |
# console.log('Something is wrong:', error.message); | |
# }); | |
# } | |
# SignIn(email: string, password: string) { | |
# this.angularFireAuth | |
# .auth | |
# .signInWithEmailAndPassword(email, password) | |
# .then(res => { | |
# console.log('Successfully signed in!'); | |
# }) | |
# .catch(err => { | |
# console.log('Something is wrong:',err.message); | |
# }); | |
# } | |
# SignOut() { | |
# this.angularFireAuth | |
# .auth | |
# .signOut(); | |
# } | |
# } | |
# more stuff here: | |
# https://www.positronx.io/firebase-authentication-in-angular-8-with-angularfire2/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment