Reputation: 191
I'm building a custom account system with meteor accounts package when i register a new user accounts is loggin him directly (a behavior that i does'nt asked) and meteor toys shows one user in collection (despite the others that i have added previously) this is because i didn't publish users. When i'm creating a new user with existing username it returns an error but also redirect and the user is logged in please i need help with this
// Meteor server side method for register
Meteor.methods({
'users.register'( data ) {
try {
user = Accounts.createUser({
username: data.username,
password: data.password,
});
return {
"userId": user
};
} catch (e) {
throw e;
}
},
});
// register call on register.js (client side register page)
Meteor.call('users.register', registerable, ( error ) => {
if( error ){
if( error.error == 403 ){
usernameExistMessage.style.display = "inline";
} else {
usernameExistMessage.style.display = "none";
}
}
});
// Users in the mongo collection
{ "_id" : "7re7XPXoxrs6oYckN", "createdAt" : ISODate("2019-01-18T16:51:31.742Z"), "services" : { "password" : { "bcrypt" : "$2a$10$8NZwd1gPMpJgMs8P47DF.uHWrvBLilTBcp6D0q6877HcDJOfJKaz6" }, "resume" : { "loginTokens" : [ ] } }, "username" : "test" }
{ "_id" : "96rc3NYXr35HNB6uZ", "createdAt" : ISODate("2019-01-18T16:52:07.421Z"), "services" : { "password" : { "bcrypt" : "$2a$10$Y3Bb6B/o3MwnFevNGpqtROMcH833qtHF.OEx6Qg5xbJrwXRU2u.2q" }, "resume" : { "loginTokens" : [ ] } }, "username" : "username" }
User auto logged in after creation of a new account even if the user already exist in mongo user collection
My meteor package file
meteor-base@1.4.0 # Packages every Meteor app needs to have
mobile-experience@1.0.5 # Packages for a great mobile UX
mongo@1.6.0 # The database Meteor supports right now
blaze-html-templates@1.0.4 # Compile .html files into Meteor Blaze views
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.2.0 # Meteor's client-side reactive programming library
standard-minifier-css@1.5.2 # CSS minifier run for production mode
standard-minifier-js@2.4.0 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.12.4 # Enable ECMAScript2015+ syntax in app code
shell-server@0.4.0 # Server-side component of the `meteor shell` command
accounts-password
kadira:flow-router
kadira:blaze-layout
fastclick
less@2.8.0 # Leaner CSS language
aldeed:simple-schema
aldeed:collection2
alanning:roles
meteortoys:allthings
Upvotes: 0
Views: 67
Reputation: 191
I solved my issue there was some wrong imports and a template events bad handling
Upvotes: 0