Search code examples
meteoruser-accounts

meteor: show alert on created user


I want to show to the user a message like: "I have sent a email to activate your account".

I cannot because when the user has been created I have not found a hook for this.

Do you know some way to do this?

I currently show a message permanently, but I don't want this way. I just want to show once when user is singed up.


Solution

  • Well there are 2 options here, if you are creating the user on the client side, just use

    Accounts.createUser({email: email, password: password}, function(err) {
     if(!err){
       alert(""I have sent a email to activate your account")
      }
    });
    

    Or if you are creating the user from a method, it should look like this.

    //Server.js
        Meter.method({
         createUser:function(username,email,password){
           //create user logic.
          }
        })
    

    And on the client it should look like this.

    Meteor.call('createUser',username,email,password,function(err,result){
      if(!err){
       alert(""I have sent a email to activate your account")
      }
    });
    

    On both cases we are using an extra parameter, named callback this function, accept 2 other parameters wich are err,result, so if there is not error when the accounts its created, the alert should be triggered