2
0

accounts.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const passwordField = AccountsTemplates.removeField('password');
  2. const emailField = AccountsTemplates.removeField('email');
  3. AccountsTemplates.addFields([{
  4. _id: 'username',
  5. type: 'text',
  6. displayName: 'username',
  7. required: true,
  8. minLength: 2,
  9. }, emailField, passwordField, {
  10. _id: 'invitationcode',
  11. type: 'text',
  12. displayName: 'Invitation Code',
  13. required: false,
  14. minLength: 6,
  15. errStr: 'Invitation code doesn\'t exist',
  16. template: 'invitationCode',
  17. }]);
  18. AccountsTemplates.configure({
  19. defaultLayout: 'userFormsLayout',
  20. defaultContentRegion: 'content',
  21. confirmPassword: false,
  22. enablePasswordChange: true,
  23. sendVerificationEmail: true,
  24. showForgotPasswordLink: true,
  25. onLogoutHook() {
  26. const homePage = 'home';
  27. if (FlowRouter.getRouteName() === homePage) {
  28. FlowRouter.reload();
  29. } else {
  30. FlowRouter.go(homePage);
  31. }
  32. },
  33. });
  34. ['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'].forEach(
  35. (routeName) => AccountsTemplates.configureRoute(routeName));
  36. // We display the form to change the password in a popup window that already
  37. // have a title, so we unset the title automatically displayed by useraccounts.
  38. AccountsTemplates.configure({
  39. texts: {
  40. title: {
  41. changePwd: '',
  42. },
  43. },
  44. });
  45. AccountsTemplates.configureRoute('changePwd', {
  46. redirect() {
  47. // XXX We should emit a notification once we have a notification system.
  48. // Currently the user has no indication that his modification has been
  49. // applied.
  50. Popup.back();
  51. },
  52. });
  53. if (Meteor.isServer) {
  54. ['resetPassword-subject', 'resetPassword-text', 'verifyEmail-subject', 'verifyEmail-text', 'enrollAccount-subject', 'enrollAccount-text'].forEach((str) => {
  55. const [templateName, field] = str.split('-');
  56. Accounts.emailTemplates[templateName][field] = (user, url) => {
  57. return TAPi18n.__(`email-${str}`, {
  58. url,
  59. user: user.getName(),
  60. siteName: Accounts.emailTemplates.siteName,
  61. }, user.getLanguage());
  62. };
  63. });
  64. }