Meteor.. accounts- password-- 在客户端创建账户无需登录
Meteor.. accounts- password-- Create account on client without login
我正在使用 accounts-password package - Meteor。
我为管理员编写界面代码。
管理员将为其他用户创建帐户。
Accounts.createUser({
email: "abc@gmail.com",
password : "abc123",
profile: { name: register_name }
});
但是执行此代码后,我的应用程序自动使用帐户 abc@gmail.com 登录,我不想要它
问题
如何创建没有自动登录的账户?
我阅读了 accounts-password
来源,但我不知道如何删除自动登录
我也尝试过使用 Meteor.users.insert 函数,但是 Accounts.setPassword
没有用..
这是使用帐户包的正常行为,为避免混淆源代码,请使用 Meteor.method/Meteor.call。
这是一个简单的示例,您也可以使用默认的 username
字段而不是 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 )
}
})
}
})
}
有了这个,您可以在管理模板上创建多个帐户,并在注册模板上保留自动登录行为(如果您有的话)
我正在使用 accounts-password package - Meteor。
我为管理员编写界面代码。
管理员将为其他用户创建帐户。
Accounts.createUser({
email: "abc@gmail.com",
password : "abc123",
profile: { name: register_name }
});
但是执行此代码后,我的应用程序自动使用帐户 abc@gmail.com 登录,我不想要它
问题
如何创建没有自动登录的账户?
我阅读了 accounts-password
来源,但我不知道如何删除自动登录
我也尝试过使用 Meteor.users.insert 函数,但是 Accounts.setPassword
没有用..
这是使用帐户包的正常行为,为避免混淆源代码,请使用 Meteor.method/Meteor.call。
这是一个简单的示例,您也可以使用默认的 username
字段而不是 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 )
}
})
}
})
}
有了这个,您可以在管理模板上创建多个帐户,并在注册模板上保留自动登录行为(如果您有的话)