有没有一种方法可以将Google登录限制为Android中的某个电子邮件域? [英] Is there a way to restrict Google Sign In to a certain email domain in Android?
本文介绍了有没有一种方法可以将Google登录限制为Android中的某个电子邮件域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将应用程序中的Google登录限制为域为 @ companyname.com 的某些电子邮件?
Is there a way to restrict Google signIn in the app to certain emails with domain @companyname.com?
目标是仅允许 @ companyname.com 用户获得登录功能的访问权限.
The goal is to let only @companyname.com users only to gain access in the log in features.
我已经做过一些研究,但是我什么都还没想到.
I have done some research but I have come up with nothing yet.
推荐答案
您需要在登录后进行检查,这将是一种安全的方法
You Need To Check This After Signing In That Will Be A Secure Way To Do It
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully.
GoogleSignInAccount acct = result.getSignInAccount();
String email = acct.getEmail();
String[] split = s.split("@");
String domain = split[1]; //This Will Give You The Domain After '@'
if(domain.equals("companyname.com"))
{
//Proceed Ahead.
}
else
{
//Show User Warning UI.
}
} else {
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
这篇关于有没有一种方法可以将Google登录限制为Android中的某个电子邮件域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文