accounts.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var passwordField = AccountsTemplates.removeField('password');
  2. var 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: function() {
  18. var homePage = 'home';
  19. if (FlowRouter.getRouteName() === homePage) {
  20. FlowRouter.reload();
  21. } else {
  22. FlowRouter.go(homePage);
  23. }
  24. }
  25. });
  26. _.each(['signIn', 'signUp', 'resetPwd', 'forgotPwd', 'enrollAccount'],
  27. function(routeName) {
  28. AccountsTemplates.configureRoute(routeName);
  29. });
  30. // We display the form to change the password in a popup window that already
  31. // have a title, so we unset the title automatically displayed by useraccounts.
  32. AccountsTemplates.configure({
  33. texts: {
  34. title: {
  35. changePwd: ''
  36. }
  37. }
  38. });
  39. AccountsTemplates.configureRoute('changePwd', {
  40. redirect: function() {
  41. // XXX We should emit a notification once we have a notification system.
  42. // Currently the user has no indication that his modification has been
  43. // applied.
  44. Popup.back();
  45. }
  46. });