Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

javascript - 在linkWithCredential()上触发Firebase Cloud函数(Trigger Firebase Cloud Function on linkWithCredential())

I'm trying set custom claims for users who have a company email.(我正在尝试为拥有公司电子邮件的用户设置自定义声明。)

Everything works fine when I use .onCreate() trigger, but since I log in users anonymously, I don't know how I can trigger this function at the right time (at signup, when the email is available).(当我使用.onCreate()触发器时,一切正常,但是由于我匿名登录用户,所以我不知道如何在正确的时间(注册时,如果有电子邮件可用)触发此功能。) Is my only resort to use a https callable cloud function ?(我唯一使用https可调用云函数的方法吗?) I'd rather not expose this one.(我宁愿不公开这个。) Is there another way to set custom claims for special login cases i'm unaware of ?(是否有另一种方法可以为我不知道的特殊登录情况设置自定义声明?)   ask by user3528232 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The only Authentication triggers that are available for Cloud Functions are when the user account is first created, and when it gets deleted.(Cloud Functions唯一可用的身份验证触发器是在首次创建用户帐户时以及在删除用户帐户时。)

There is no trigger to run a function when an email gets added or verified, not when two identity providers are linked to the same account.(添加或验证电子邮件时(没有将两个身份提供者链接到同一帐户),没有触发运行功能的触发器。) The standard way to do what you want is to use another trigger type (such as a callable function as you already said), validate in there that the user is indeed entitled to the custom claim, and then add that claim to their profile.(执行所需操作的标准方法是使用另一种触发器类型(例如您已经说过的可调用函数),在其中验证用户确实有权获得自定义声明,然后将该声明添加到他们的个人资料中。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...