gpt4 book ai didi

authentication - 如何在 Meteor 上注册后创建一个没有自动登录的用户

转载 作者:行者123 更新时间:2023-12-02 06:17:09 26 4
gpt4 key购买 nike

我正在构建一个 Meteor 应用程序,我需要在用户创建帐户后删除 Meteor 的自动登录。

我正在为 UI 使用帐户密码和帐户条目(可选)。

有什么想法吗?谢谢。

最佳答案

这是一个通过电子邮件登录的简单解决方案,它会在用户创建后停用自动登录并拒绝以后的登录,直到电子邮件地址得到验证:

if (Meteor.isServer) {

Accounts.validateLoginAttempt(function(attemptInfo) {

if (attemptInfo.type == 'resume') return true;

if (attemptInfo.methodName == 'createUser') return false;

if (attemptInfo.methodName == 'login' && attemptInfo.allowed) {
var verified = false;
var email = attemptInfo.methodArguments[0].user.email;
attemptInfo.user.emails.forEach(function(value, index) {
if (email == value.address && value.verified) verified = true;
});
if (!verified) throw new Meteor.Error(403, 'Verify Email first!');
}

return true;
});

}

关于authentication - 如何在 Meteor 上注册后创建一个没有自动登录的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25642358/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com