本文整理汇总了TypeScript中firebase-admin.auth函数的典型用法代码示例。如果您正苦于以下问题:TypeScript auth函数的具体用法?TypeScript auth怎么用?TypeScript auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auth函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getAllUsers
/**
* Get a list of users
*
* @param {number} [maxResults=1000]
* @returns {Promise<any>}
* @memberof FirebaseHelper
*/
getAllUsers(maxResults: number = 1000): Promise<any> {
return admin.auth().listUsers(maxResults)
.then((listUsersResult) => listUsersResult.users)
.catch((error) => {
console.log("Error listing users:", error);
});
}
示例2:
.firestore.document('/users/{userId}').onDelete((change, context) => {
// console.log(change.after.data());
// console.log(context.params.userId);
const userId: string = context.params.userId;
return admin.auth().deleteUser(userId);
});
示例3: Promise
return new Promise(resolve => {
admin.auth().deleteUser(userId)
.then(() => {
resolve(true);
})
.catch(error => {
console.log(error);
resolve(false);
})
})
示例4:
.catch(err => {
if (err.message === 'The user with the provided uid already exists.') {
return admin.auth().updateUser('uchicago:' + uid, {
displayName,
email,
emailVerified: true,
});
}
throw err;
});
示例5: getToken
static async getToken({ uid, displayName, email }: User): Promise<string> {
await admin
.auth()
.createUser({
uid: 'uchicago:' + uid,
displayName,
email,
emailVerified: true,
})
.catch(err => {
if (err.message === 'The user with the provided uid already exists.') {
return admin.auth().updateUser('uchicago:' + uid, {
displayName,
email,
emailVerified: true,
});
}
throw err;
});
return admin.auth().createCustomToken('uchicago:' + uid);
}
示例6: create
static async create(uid, displayName, email) {
await admin
.auth()
.createUser({
uid,
displayName,
email,
emailVerified: true,
})
.catch(err => {
if (err.message === 'The user with the provided uid already exists.') {
return admin.auth().updateUser(uid, {
displayName,
email,
emailVerified: true,
});
}
throw err;
});
return admin.auth().createCustomToken(uid);
}
示例7:
.firestore.document('/users/{userId}').onUpdate((change, context) => {
// console.log(change.after.data());
// console.log(context.params.userId);
const data: any = change.after.data();
const userId: string = context.params.userId;
return admin.auth().updateUser(userId, {
disabled: data.isDisabled
});
});
示例8: getUserByPhone
/**
* Get User Info though phone number
*
* @param {string} phone
* @returns {Promise<any>}
* @memberof FirebaseHelper
*/
getUserByPhone(phone: string): Promise<any> {
return admin.auth().getUserByPhoneNumber(phone)
.then(user => user)
.catch(error => console.log(error))
}
示例9: getUserByEmail
/**
* Get User Info though email
*
* @param {string} email
* @returns {Promise<any>}
* @memberof FirebaseHelper
*/
getUserByEmail(email: string): Promise<any> {
return admin.auth().getUserByEmail(email)
.then(user => user)
.catch(error => console.log(error))
}