如何验证用户是否来自我的 6 个域之一
How to verify a user is from one of my 6 domains
<script type="text/javascript">
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId());
console.log("Email: " + profile.getEmail());
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
if(id_token !="")
{
window.location = 'support.php';
}
};
</script>
我已经做了相当多的搜索,似乎找不到我要找的东西。上面的代码是我所拥有的。我需要它做的是以下内容。
我有 6 个域访问同一个网站。我想拥有它,以便只有这六个谷歌域可以登录。如果您的电子邮件与六个域之一不匹配,它将带您进入错误页面。我该怎么做?任何帮助将不胜感激。
如果你真的在寻找PHP而不是javascript,那么这样的东西应该可以工作:
$email = $_POST['email'];
$allowed = array('domain1.com', 'domain2.com', 'domain3.com');
// Make sure the address is valid
if (filter_var($email, FILTER_VALIDATE_EMAIL))
{
$explodedEmail = explode('@', $email);
$domain = array_pop($explodedEmail);
if ( ! in_array($domain, $allowed))
{
// Not allowed
header('Location: http://example.com/myOtherPage.php');
}
}
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 可以't让我的if语句处理js中的html表单输入
- 我的单元测试选项是什么
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 我的职位回报太快了,如何做出承诺
- 我的jQuery插件参数没有正确启动,遇到了问题
- 如何识别我的网站中的慢速设备
- 如何将JSON数据导入我的ejs模板
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 知道为什么我的旋转木马不会自动更改图片吗
- 我的模板未被解析
- 无法将数据从firebase获取到我的html页面
- 角度图表;t显示在我的页面中
- 我的AngularJS表达式没有'不起作用
- 将电视直播频道从网站嵌入我的网站
- /undefined在我的404错误日志中多次出现
- 为什么我的d3.jsselectAll+过滤器没有过滤
- 元素在我的代码中不会.fadeTo.Don'I don’我不知道;s错误的JavaScript、JQuery、H
- 显示来自我的控制器的错误消息,并重定向回我的主页
- 数据表不加载时,我重定向我的页面使用自我.do_action在odoo(openERP7) qweb屏幕