简体   繁体   English

JHipster社交登录-将电子邮件设为必填字段

[英]JHipster Social Login - make email a mandatory field

I just setup the basic JHipster application and set in the FB client ID and secret. 我只是设置了基本的JHipster应用程序,并设置了FB客户端ID和密码。 However, when I try to login by not sharing the email - I see that it gets redirected to my app with a success. 但是,当我尝试通过不共享电子邮件进行登录时-我看到它成功重定向到了我的应用程序。 I can handle the no email exception on application. 我可以处理应用程序上的无电子邮件例外。

Instead , I wanted FB to make sure that my email was a mandatory field. 相反,我希望FB确保我的电子邮件是必填字段。 How do I do that? 我怎么做?

You can't force Facebook to return an email address for a user. 您不能强迫Facebook返回用户的电子邮件地址。 It may also be null on their end (if the user signed up with a phone number). 它们的一端也可能为null(如果用户使用电话号码注册)。 You will have to handle it in your application. 您将不得不在您的应用程序中处理它。 This is the same case with Twitter - they simply don't provide the user's email. Twitter也是如此-他们只是不提供用户的电子邮件。

Note, even if you request the email permission it is not guaranteed you will get an email address. 请注意,即使您请求电子邮件许可,也不能保证您将获得一个电子邮件地址。 For example, if someone signed up for Facebook with a phone number instead of an email address, the email field may be empty. 例如,如果某人使用电话号码而不是电子邮件地址注册了Facebook,则电子邮件字段可能为空。

https://developers.facebook.com/docs/facebook-login/permissions/ https://developers.facebook.com/docs/facebook-login/permissions/

Like you mentioned, you need to handle it in your application. 就像您提到的那样,您需要在应用程序中处理它。 You could catch the fact the email is null and prompt the user to enter an email. 您可能会发现电子邮件为空的事实,并提示用户输入电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM