Custom Meteor Registration Template

In my application, I want to sow the database with users and send them a link to activate my account (and select a password). I also want them to check / modify some profile data.

On the server, I seed the database as follows:

Meteor.startup(function () {
  if(Meteor.users.find().count() === 0) {
    var user_id = Accounts.createUser({ email: 'some@email.com', profile: { some: 'profile' } });
    Accounts.sendEnrollmentEmail(user_id);
  }
})

The registration link is sent as expected, but I want to create a custom template when I click the URL in the email. Preferably handled by an iron router. (Do not use ui account pack).

I tried things like redirecting a user to a user route as follows:

var doneCallback, token;

Accounts.onEnrollmentLink(function (token, done) {
  doneCallback = done;
  token = token;
  Router.go('MemberEnroll')
});

which doesn't work (it changes the url but doesn't display my pattern)

I also tried changing the server registration URL as follows:

Accounts.urls.enrollAccount = function (token) {
  return Meteor.absoluteUrl('members/enroll/' + token);
};

, Accounts.onEnrollmentLink . , URL- , , .

.

+4
2

        this.route('enroll', {
            path: '/enroll-account/:token',
            template: 'enroll_page',
            onBeforeAction: function() {
                Meteor.logout();
                Session.set('_resetPasswordToken', this.params.token);
                this.subscribe('enrolledUser', this.params.token).wait();
            },
            data: function() {
                if(this.ready()){
                    return {
                        enrolledUser: Meteor.users.findOne()
                    }
                }
            }
       })

URL-

http://www.yoursite.com/enroll-account/hkhk32434kh42hjkhk43

, ,

Meteor.publish('enrolledUser', function(token) {
    return Meteor.users.find({"services.password.reset.token": token});
});

Accounts.resetPassword(token, creds.password,function(e,r){
  if(e){
    alert("Sorry we could not reset your password. Please try again.");
  }else{
    alert("Logged In");
    Router.go('/');
   }
 })

Accounts.urls.enrollAccount = function (token) {
  return Meteor.absoluteUrl('enroll-account/' + token);
};
+13

, , , html css "rendered",

Meteor.startup(function(){
    Template["_enrollAccountDialog"].rendered = function(){
        document.getElementById('enroll-account-password-label').innerHTML = 'Escolha sua senha';
        $('.accounts-dialog').css('background-color','#f4f5f5');
        $('.accounts-dialog').css('text-align','center');
        $('.accounts-dialog').removeAttr('width');
        document.getElementById('login-buttons-enroll-account-button').className = ' create-account-button'; 
        document.getElementById('login-buttons-enroll-account-button').innerHTML = 'Criar conta';
    }
});
0

Source: https://habr.com/ru/post/1568548/


All Articles