pleroma-fe/src/services/new_api/password_reset.js

22 lines
480 B
JavaScript
Raw Normal View History

2019-09-05 11:23:28 +00:00
import { reduce } from 'lodash'
2022-07-31 12:35:48 +03:00
const MASTODON_PASSWORD_RESET_URL = '/auth/password'
2019-09-05 11:23:28 +00:00
const resetPassword = ({ instance, email }) => {
const params = { email }
2026-01-06 16:22:52 +02:00
const query = reduce(
params,
(acc, v, k) => {
const encoded = `${k}=${encodeURIComponent(v)}`
return `${acc}&${encoded}`
},
'',
)
2019-09-05 11:23:28 +00:00
const url = `${instance}${MASTODON_PASSWORD_RESET_URL}?${query}`
return window.fetch(url, {
2026-01-06 16:22:52 +02:00
method: 'POST',
2019-09-05 11:23:28 +00:00
})
}
export default resetPassword