accountPassword.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {JsonFormObject} from 'sentry/components/forms/type';
  2. const getUserIsNotManaged = ({user}) => !user.isManaged;
  3. const formGroups: JsonFormObject[] = [
  4. {
  5. // Form "section"/"panel"
  6. title: 'Password',
  7. fields: [
  8. {
  9. name: 'password',
  10. type: 'secret',
  11. autoComplete: 'current-password',
  12. label: 'Current Password',
  13. placeholder: '',
  14. help: 'Your current password',
  15. visible: getUserIsNotManaged,
  16. required: true,
  17. },
  18. {
  19. name: 'passwordNew',
  20. type: 'secret',
  21. autoComplete: 'new-password',
  22. label: 'New Password',
  23. placeholder: '',
  24. help: '',
  25. required: true,
  26. visible: getUserIsNotManaged,
  27. validate: ({id, form}) => (form[id] !== form.passwordVerify ? [[id, '']] : []),
  28. },
  29. {
  30. name: 'passwordVerify',
  31. type: 'secret',
  32. autoComplete: 'new-password',
  33. label: 'Verify New Password',
  34. placeholder: '',
  35. help: 'Verify your new password',
  36. required: true,
  37. visible: getUserIsNotManaged,
  38. validate: ({id, form}) => {
  39. // If password is set, and passwords don't match, then return an error
  40. if (form.passwordNew && form.passwordNew !== form[id]) {
  41. return [[id, 'Passwords do not match']];
  42. }
  43. return [];
  44. },
  45. },
  46. ],
  47. },
  48. ];
  49. export const route = '/settings/account/security/';
  50. export default formGroups;