当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript firebase-functions.auth类代码示例

本文整理汇总了TypeScript中firebase-functions.auth的典型用法代码示例。如果您正苦于以下问题:TypeScript auth类的具体用法?TypeScript auth怎么用?TypeScript auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了auth类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: msg

import * as functions from 'firebase-functions';
import { sgMail, msg } from './email';
import { db } from './config';

export const newUserSetup = functions.auth.user().onCreate(async (user, context) => {

    const ref = db.collection('users').doc(user.uid);
    const { uid, displayName, photoURL, email } = user;
    await ref.set({
        uid, displayName, photoURL, email,
        joined: Date.now()
    })

    const body = 'Welcome to Fireship.io!';
    const subject = 'Welcome aboard!';

    const emailMsg = msg([email], { body, subject });

    return await sgMail.send(emailMsg);
})
开发者ID:janjachacz,项目名称:fireship.io,代码行数:20,代码来源:user.ts

示例2: data

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

const firestore = admin.firestore();

/**
 * Cloud Function that adds information about a newly logged-in Firebase user to the associated document in Cloud Firestore.
 * This function is triggered when a new user is authenticated.
 * 
 * TODO: Fix broken function
 */
export const appendUserInfo = functions.auth.user().onCreate((user, context) => {
  console.log('User data (as JSON):', user.toJSON());
  console.log('User data (raw):', user);
  // The following lines of code are adapted from the Firebase Functions source code.
  // See 
  return firestore.doc(`users/${user.uid}`)
  .set({
    user: JSON.parse(JSON.stringify(user))
  });
})
开发者ID:EdricChan03,项目名称:studybuddy-cloud-functions,代码行数:21,代码来源:append-user-info.ts

示例3:

import * as functions from "firebase-functions";

// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
// export const helloWorld = functions.https.onRequest((request, response) => {
//  response.send("Hello from Firebase!");
// });

export const saveUser = functions.auth.user().onCreate(user => {
  const id = user.uid;
  const email = user.email; // The email of the user.
  const displayName = user.displayName; // The display name of the user.
  console.log(id, email, displayName);
});
开发者ID:ajheunis,项目名称:firebase-test-2,代码行数:15,代码来源:index.ts

示例4: while

                        name: transaction.name,
                        note: transaction.note || null,
                        recurring: change.after.key,
                        transfer: transaction.transfer || null
                    });
                }
                date = date.add(transaction.period);
            } while (date.toFbString() <= transaction.end);

            return true;
        } else if (transaction.delete) {
            let trRef = change.after.ref.parent.parent.child('transactions');
            let snapshot = await trRef.orderByChild('date').startAt(transaction.delete).once('value');
            let values = snapshot.val();
            for (let key in values) {
                if (values[key].recurring == change.after.key)
                    await snapshot.child(key).ref.remove();
            }

            await change.after.ref.child('delete').remove();

            return true;
        }
    }
    return false;
}

exports.handleRecurring = functions.database.ref('/{user}/accounts/{account}/recurring/{key}').onWrite(handleRecurring);
exports.createUser = functions.auth.user().onCreate(setupUser);
exports.removeUser = functions.auth.user().onDelete(removeUserData);
开发者ID:mlaanderson,项目名称:firebase-budget,代码行数:30,代码来源:index.ts


注:本文中的firebase-functions.auth类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。