DonFabiolas
DonFabiolas

Reputation: 599

TheMeteorChef createUser Methods already exists?

I don't understand, I created this method

import { Accounts } from 'meteor/accounts-base';
import SimpleSchema from 'simpl-schema';
import { ValidatedMethod } from 'meteor/mdg:validated-method';

export const createUser = new ValidatedMethod({
  name: 'createUser',
  validate: new SimpleSchema({
    email: { type: String, optional: true },
  }).validator(),
  run({email}) {
    if (this.isSimulation) return true;
    ;

    const userId = Accounts.createUser({ email, password:'coucou' });

    return 'ok'
  },
});

and when I call it :

import { createUser } from '../../../api/auth/methods.js'

createUser.call({ email: this.email.value }, function(err, data) {
    if(err){
      console.log('err: ', err);
    }else{
        console.log('data: ', data);
    }

I have this error in server side :

Error: A method named 'createUser' is already defined

So, if I changed the method's name is working.

but, I would like to understand

1) Why 'createUser' is already defined ?

2) Where comes from 'createUser' default method ?

Thank you ;-)

Upvotes: 0

Views: 61

Answers (1)

DonFabiolas
DonFabiolas

Reputation: 599

I found this issue,

'createUser' comes from 'accounts-password package' when you do : meteor add accounts-password

you can check in your application

/MyAPPLICATION/.meteor/local/build/programs/server/packages/accounts-password.js

we can find this :

Meteor.methods({                                                                                                      
createUser: function (options) {  ...

Upvotes: 1

Related Questions