流星..帐户-密码-在客户端上创建帐户而无需登录 [英] Meteor.. accounts- password-- Create account on client without login

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

问题描述

我正在使用帐户密码包-流星。

我为管理员编写了代码界面。

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?

我阅读了帐户密码来源,但我不知道如何删除自动登录

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..

推荐答案

这是使用accounts包的正常行为,为避免与源代码混淆,请使用 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.

这是一个简单的示例,您也可以使用默认的用户名归档并不是配置文件:{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)

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

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