Meteor..账户-密码--无需登录即可在客户端创建账户

标签 meteor account meteor-accounts

我正在使用accounts-password package - meteor 。

我为管理员编写了界面。

管理员将为其他用户创建帐户。

Accounts.createUser({
        email: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="18797a7b587f75797174367b7775" rel="noreferrer noopener nofollow">[email protected]</a>", 
        password : "abc123", 
        profile: { name: register_name }
   });

但是执行此代码后,我的应用程序自动使用帐户登录 [email protected] ,但我不想要它

问题

如何创建不自动登录的帐户?

我阅读了accounts-password源代码,但我不知道如何删除自动登录

我也尝试使用 Meteor.users.insert 函数,但 Accounts.setPassword 不起作用..

最佳答案

这是使用帐户包的正常行为,为避免弄乱源代码,请使用 Meteor.method/Meteor.call .

这是一个简单的示例,您也可以使用默认提交的用户名,而不是个人资料:{name:register_name}

    if(Meteor.isServer){
        Meteor.methods({
          createUserFromAdmin:function(emai,password,username){
            Accounts.createUser({email:email,password:password,username:username})
      }
    })
   }else if(Meteor.isClient){
        Template.admin.events({
         'click #createAccount':function(){
           Meteor.call('createUserFromAdmin',email,password,username,function(err,result){
              if(!err){
                 console.log("a new user just got created")
                }else{
                  console.log("something goes wrong with the following error message " +err.reason )
                }
             })
           }
        })
       }

通过此功能,您可以在管理模板上创建多个帐户,并在注册模板上保留自动登录行为(如果有的话)

关于Meteor..账户-密码--无需登录即可在客户端创建账户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29453829/

相关文章:

javascript - 将 meteor 应用程序部署到域和别名

xcode - 在 Xcode 7 上,我不断收到错误 "No accounts with iTunes connect access"

meteor - 在Meteor中正确使用onResetPasswordLink,onEnrollmentLink和onEmailVerificationLink方法

cookies - Meteor 在客户端和服务器之间共享 session 数据

css - 如何使集合标题保持在顶部并使集合项可滚动?

Meteor bundle 可视化工具将动态导入添加到初始客户端 bundle

templates - 在哪里定义可以在模板助手中重用的 Meteor 助手函数

android - 是否可以使用 aadhaar 卡详细信息制作应用/创建应用计数?

android - 如何从设置 UI 中隐藏我的客户客户经理

javascript - 如何启用 Account.users 可编辑或如何删除或编辑 Meteor.users() 的用户?