Skip to content

Instantly share code, notes, and snippets.

Avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
@codediodeio
codediodeio / auth.service.ts
Last active Jan 8, 2020
Service for Angular4 + Firebase Authentication
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireAuth, AngularFireDatabase, FirebaseAuthState, AuthProviders, AuthMethods, AngularFire } from "angularfire2";
import { Router } from "@angular/router";
import * as firebase from 'firebase';
@Injectable()
export class AuthService {
View auth.service.ts
import { Injectable } from '@angular/core';
import * as firebase from 'firebase';
//...omitted
@Injectable()
export class AuthService {
resetPassword(email: string) {
var auth = firebase.auth();
return auth.sendPasswordResetEmail(email)
@codediodeio
codediodeio / auth.guard.ts
Last active Aug 28, 2020
Angular Firebase Router Guard with Browser Refresh
View auth.guard.ts
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take';
@Injectable()
export class AuthGuard implements CanActivate {
@codediodeio
codediodeio / auth.service.ts
Created May 8, 2017
Angular4 Firebase authentication service using OAuth, Anonymous, and Email/Password. Designed specifically for changes introduced in AngularFire2 4.0.0
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { AngularFireAuth } from 'angularfire2/auth';
import { Router } from "@angular/router";
import * as firebase from 'firebase';
@Injectable()
export class AuthService {
@codediodeio
codediodeio / auth.service.ts
Last active May 12, 2017
AngularFire2 Auth service that merges custom data from the database
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireAuth } from "angularfire2/auth";
import { AngularFireDatabase } from "angularfire2/database";
import * as firebase from 'firebase';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export class User {
uid: string;
username:string;
View auth.service.ts
import { Injectable } from '@angular/core';
import { AngularFireAuth } from "angularfire2/auth";
import { AngularFireDatabase } from "angularfire2/database";
import * as firebase from 'firebase';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export class User {
uid: string;
username:string;
@codediodeio
codediodeio / index.js
Last active Jan 23, 2021
Transactional Email Firebase Cloud Function with Sendgrid
View index.js
var functions = require('firebase-functions');
const sendgrid = require('sendgrid')
const client = sendgrid("YOUR_SG_API_KEY")
function parseBody(body) {
var helper = sendgrid.mail;
var fromEmail = new helper.Email(body.from);
var toEmail = new helper.Email(body.to);
var subject = body.subject;
@codediodeio
codediodeio / send-email.component.html
Last active Apr 19, 2018
Trigger HTTP Cloud Function via Angular Component (for transactional email)
View send-email.component.html
<button (click)="sendEmail()">Send Email via Cloud Function</button>
@codediodeio
codediodeio / database.rules.json
Last active Apr 12, 2021
Common Database Rules for Firebase
View database.rules.json
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@codediodeio
codediodeio / index.js
Created Jun 24, 2017
English to any language as a background task with Firebase cloud functions.
View index.js
var functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const request = require('request-promise');
const _ = require('lodash');
// List of output languages.
const LANGUAGES = ['es', 'fr', 'ar'];