Meteor..账户-密码--无需登录即可在客户端创建账户 [英] Meteor.. accounts- password-- Create account on client without login

查看:33
本文介绍了Meteor..账户-密码--无需登录即可在客户端创建账户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 accounts-password 包 - Meteor.

I'm using accounts-password package - Meteor.

我为管理员编写代码界面.

I code interface for admin.

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

Admin will create accounts for other user.

Accounts.createUser({
        email: "abc@gmail.com", 
        password : "abc123", 
        profile: { name: register_name }
   });

但执行此代码后,我的应用程序自动使用帐户abc@gmail.com 登录,我不想要它

But after this code executed, my application automatic login with account abc@gmail.com, wich i don't want it

问题

如何在没有自动登录的情况下创建帐户?

How to create accounts without automatic login?

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

I read accounts-password source but i dont know how to remove automatic login

我也尝试过使用 Meteor.users.insert 函数但是 Accounts.setPassword 没有用..

I also tried to use Meteor.users.insert function but Accounts.setPassword didn't work..

推荐答案

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

This is a normal behavior using accounts package, to avoid messing with the source code use a Meteor.method/Meteor.call.

这是一个简单的例子,您也可以使用默认的username 归档而不是profile:{name:register_name}.

This is a simple example,also you can use the default username filed and not a profile:{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 )
                }
             })
           }
        })
       }

有了这个,您可以在管理模板上创建多个帐户,并在注册模板上保持自动登录行为(如果有的话)

With this you can create multiple accounts on the admin template, and keep the autologin behavior on the sign-up template (if you have one)

这篇关于Meteor..账户-密码--无需登录即可在客户端创建账户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆