| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 | const passwordField = AccountsTemplates.removeField('password');const emailField = AccountsTemplates.removeField('email');let disableRegistration = true;let disableForgotPassword = true;Meteor.call('getDisableRegistration', (err, data) => {  if (!err) {    disableRegistration = data;    //console.log(data);  }});Meteor.call('getDisableForgotPassword', (err, data) => {  if (!err) {    disableForgotPassword = data;    //console.log(data);  }});AccountsTemplates.addFields([  {    _id: 'username',    type: 'text',    displayName: 'username',    required: true,    minLength: 2,  },  emailField,  passwordField,  {    _id: 'invitationcode',    type: 'text',    displayName: 'Invitation Code',    required: false,    minLength: 6,    template: 'invitationCode',  },]);AccountsTemplates.configure({  defaultLayout: 'userFormsLayout',  defaultContentRegion: 'content',  confirmPassword: true,  enablePasswordChange: true,  sendVerificationEmail: true,  showForgotPasswordLink: !disableForgotPassword,  forbidClientAccountCreation: disableRegistration,  onLogoutHook() {    const homePage = 'home';    if (FlowRouter.getRouteName() === homePage) {      FlowRouter.reload();    } else {      FlowRouter.go(homePage);    }  },});if (!disableForgotPassword) {  [    'forgotPwd',    'resetPwd',  ].forEach(routeName => AccountsTemplates.configureRoute(routeName));}if (!disableRegistration) {  [    'signUp',  ].forEach(routeName => AccountsTemplates.configureRoute(routeName));}[  'signIn',  'enrollAccount',].forEach(routeName => AccountsTemplates.configureRoute(routeName));// We display the form to change the password in a popup window that already// have a title, so we unset the title automatically displayed by useraccounts.AccountsTemplates.configure({  texts: {    title: {      changePwd: '',    },  },});AccountsTemplates.configureRoute('changePwd', {  redirect() {    // XXX We should emit a notification once we have a notification system.    // Currently the user has no indication that his modification has been    // applied.    Popup.back();  },});if (Meteor.isServer) {  [    'resetPassword-subject',    'resetPassword-text',    'verifyEmail-subject',    'verifyEmail-text',    'enrollAccount-subject',    'enrollAccount-text',  ].forEach(str => {    const [templateName, field] = str.split('-');    Accounts.emailTemplates[templateName][field] = (user, url) => {      return TAPi18n.__(        `email-${str}`,        {          url,          user: user.getName(),          siteName: Accounts.emailTemplates.siteName,        },        user.getLanguage(),      );    };  });}
 |