Dear, I can not redirect a login to the profiles template in meteor with iron: router: I DO NOT ALSO SHOW THE TEMPLATE: profiles.html
main.js
import { Template } from 'meteor/templating';
import { Meteor } from 'meteor/meteor';
import { Router } from 'meteor/iron:router';
import '../lib/routes/routes';
import './main.html';
import './template/registro/registro';
import './template/perfiles/perfiles';
Modal.allowMultiple=true;
if(Meteor.isClient){
Template.registro.events({
'submit #register-form': function(event, template) {
event.preventDefault();
var nombreVar = template.find('#nombre').value;
var apellidoVar = template.find('#apellido').value;
var emailVar = template.find('#email').value;
var telefonoVar = template.find('#telefono').value;
var password1Var = template.find('#password1').value;
var password2 = template.find('#password2').value;
//console.log(password1Var+nombreVar+apellidoVar+emailVar+telefonoVar+password2);
var userObject = {
name : nombreVar,
firts_name : apellidoVar,
email :emailVar,
phone : telefonoVar,
password : password1Var
};
Accounts.createUser(userObject,function(err){
console.log(Meteor.user());
});
}
,'submit #login-form':function(event,template){
event.preventDefault();
var emailVar = template.find('#login-email').value;
var password1Var = template.find('#login-password').value;
console.log(emailVar+password1Var);
var userLogin = {
email :emailVar,
password : password1Var
};
Meteor.loginWithPassword(emailVar,password1Var);
Modal.hide(template);
console.log("logueo : "+Meteor.userId());
}
});
Template.registro.events({
'click #Logout':function(event,template){
event.preventDefault();
Meteor.logout();
console.log("chau");
}
});
}
routes.js
import { Router } from 'meteor/iron:router';
//import { Blaze } from 'meteor/blaze';
import { Meteor } from 'meteor/meteor';
import '../../client/template/registro/registro';
import '../../client/template/perfiles/perfiles';
Router.onBeforeAction(function(){
if (!Meteor.userId()){
Router.go('/registro');
this.next();
}else{
if(Router.current().route.getName() === 'registro'){
Router.go('/perfiles');
this.next();
}
}
});
console.log("root : "+Meteor.userId());
Router.configure({
layoutTemplate :'/registro'
})
Router.route('/',{
path:'/'
})
Router.route('/perfiles',{
name:'perfiles',
path:'/perfiles'
})
Structure: