In firebase authentication, is there a way to remove a custom claim?

混江龙づ霸主 提交于 2020-02-28 05:57:05

问题


In order to set a custom claim, one uses:

admin.auth().setCustomUserClaims(uid,{claim:value});

There does exist

admin.auth().updateUser(uid,{claim:value});

...but I'm not exactly clear on how the two are different, and neither one seems to get at actually removing a previously applied custom claim.


回答1:


From the documentation:

You can delete a user's custom claims by passing null for customClaims.

So this should delete the claim:

admin.auth().updateUser(uid, {claim: null});



回答2:


I don't think you can use updateUser for this, I think you still need to call

admin.auth().setCustomUserClaims(uid, {claim:null}); 


来源:https://stackoverflow.com/questions/48175477/in-firebase-authentication-is-there-a-way-to-remove-a-custom-claim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!