firebase auth 是否可以在同一时间节点更新用户和自定义声明?
Is it possible in firebase auth to update user and custom claims at the same time node?
是否可以同时更新用户和自定义声明?
我可以通过文档中的示例更新自定义声明
admin.auth().setCustomUserClaims(uid, {admin: true}).then(() => {
});
我可以用
更新用户
firebase.auth().updateUser(request.body.user.uid, {
displayName: request.body.user.username,
email: request.body.user.email
})
我认为它会像下面的这个例子一样简单,但它一直将自定义声明保留为未定义
const customClaims = {
admin: true,
accessLevel: 9
};
firebase.auth().updateUser(request.body.user.uid, {
displayName: request.body.user.username,
email: request.body.user.email,
customClaims: customClaims
})
有没有办法同时做这两件事?还是必须分开?
updateUser method is documented to take a string uid and an UpdateRequest object. As you can see from the linked API docs, UpdateRequest doesn't have a customClaims property, or anything that lets you update the claims in the same call. You can always file a feature request 如果这对您的用例很重要。
是否可以同时更新用户和自定义声明?
我可以通过文档中的示例更新自定义声明
admin.auth().setCustomUserClaims(uid, {admin: true}).then(() => {
});
我可以用
更新用户firebase.auth().updateUser(request.body.user.uid, {
displayName: request.body.user.username,
email: request.body.user.email
})
我认为它会像下面的这个例子一样简单,但它一直将自定义声明保留为未定义
const customClaims = {
admin: true,
accessLevel: 9
};
firebase.auth().updateUser(request.body.user.uid, {
displayName: request.body.user.username,
email: request.body.user.email,
customClaims: customClaims
})
有没有办法同时做这两件事?还是必须分开?
updateUser method is documented to take a string uid and an UpdateRequest object. As you can see from the linked API docs, UpdateRequest doesn't have a customClaims property, or anything that lets you update the claims in the same call. You can always file a feature request 如果这对您的用例很重要。