Skip to content

Instantly share code, notes, and snippets.

View codediodeio's full-sized avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
@codediodeio
codediodeio / auth.service.ts
Last active January 8, 2020 20:13
Service for Angular4 + Firebase Authentication
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 {
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 August 28, 2020 02:50
Angular Firebase Router Guard with Browser Refresh
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 16:41
Angular4 Firebase authentication service using OAuth, Anonymous, and Email/Password. Designed specifically for changes introduced in AngularFire2 4.0.0
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 22:22
AngularFire2 Auth service that merges custom data from the database
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;
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 January 23, 2021 17:06
Transactional Email Firebase Cloud Function with Sendgrid
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 April 19, 2018 13:28
Trigger HTTP Cloud Function via Angular Component (for transactional email)
<button (click)="sendEmail()">Send Email via Cloud Function</button>
@codediodeio
codediodeio / database.rules.json
Last active November 4, 2024 03:22
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@codediodeio
codediodeio / index.js
Created June 24, 2017 16:59
English to any language as a background task with Firebase cloud functions.
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'];