accounts.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. AccountsTemplates.configure({
  11. defaultLayout: 'userFormsLayout',
  12. defaultContentRegion: 'content',
  13. confirmPassword: false,
  14. enablePasswordChange: true,
  15. sendVerificationEmail: true,
  16. showForgotPasswordLink: true,
  17. onLogoutHook() {
  18. const homePage = 'home';
  19. if (FlowRouter.getRouteName() === homePage) {
  20. FlowRouter.reload();
  21. } else {
  22. FlowRouter.go(homePage);
  23. }
  24. },
  25. });
  26. ['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'].forEach(
  27. (routeName) => AccountsTemplates.configureRoute(routeName));
  28. // We display the form to change the password in a popup window that already
  29. // have a title, so we unset the title automatically displayed by useraccounts.
  30. AccountsTemplates.configure({
  31. texts: {
  32. title: {
  33. changePwd: '',
  34. },
  35. },
  36. });
  37. AccountsTemplates.configureRoute('changePwd', {
  38. redirect() {
  39. // XXX We should emit a notification once we have a notification system.
  40. // Currently the user has no indication that his modification has been
  41. // applied.
  42. Popup.back();
  43. },
  44. });