accountPassword.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import type {JsonFormObject} from 'sentry/components/forms/types';
  2. import {t} from 'sentry/locale';
  3. const getUserIsNotManaged = ({user}) => !user.isManaged;
  4. const formGroups: JsonFormObject[] = [
  5. {
  6. // Form "section"/"panel"
  7. title: 'Password',
  8. fields: [
  9. {
  10. name: 'password',
  11. type: 'secret',
  12. autoComplete: 'current-password',
  13. label: t('Current Password'),
  14. help: t('Your current password'),
  15. placeholder: '',
  16. visible: getUserIsNotManaged,
  17. required: true,
  18. },
  19. {
  20. name: 'passwordNew',
  21. type: 'secret',
  22. autoComplete: 'new-password',
  23. label: t('New Password'),
  24. placeholder: '',
  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: t('Verify New Password'),
  34. help: t('Verify your new password'),
  35. placeholder: '',
  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, t('Passwords do not match')]];
  42. }
  43. return [];
  44. },
  45. },
  46. ],
  47. },
  48. ];
  49. export const route = '/settings/account/security/';
  50. export default formGroups;