本文整理汇总了TypeScript中firebase-functions.auth.user方法的典型用法代码示例。如果您正苦于以下问题:TypeScript auth.user方法的具体用法?TypeScript auth.user怎么用?TypeScript auth.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类firebase-functions.auth
的用法示例。
在下文中一共展示了auth.user方法的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);
})
示例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))
});
})
示例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);
});
示例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);