Skip to content
Snippets Groups Projects
Commit 706efc52 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

refactor(user-management): integrate with sebi's abomination

parent fafcd360
No related branches found
No related tags found
1 merge request!5Refactor component invite
...@@ -20,6 +20,7 @@ export const setAdmin = values => { ...@@ -20,6 +20,7 @@ export const setAdmin = values => {
return { return {
...omit(newValues, ['role']), ...omit(newValues, ['role']),
username: newValues.email,
isConfirmed: false, isConfirmed: false,
passwordResetToken: generatePasswordHash(), passwordResetToken: generatePasswordHash(),
password: 'defaultpass', password: 'defaultpass',
......
...@@ -31,7 +31,7 @@ const login = (dispatch, values, history) => ...@@ -31,7 +31,7 @@ const login = (dispatch, values, history) =>
const confirmUser = (email, token, history) => (values, dispatch) => { const confirmUser = (email, token, history) => (values, dispatch) => {
const request = { ...values, email, token } const request = { ...values, email, token }
if (values) { if (values) {
return create('/users/invite/password/reset', request) return create('/users/reset-password', request)
.then(r => { .then(r => {
const { username } = r const { username } = r
const { password } = values const { password } = values
...@@ -52,6 +52,7 @@ const confirmUser = (email, token, history) => (values, dispatch) => { ...@@ -52,6 +52,7 @@ const confirmUser = (email, token, history) => (values, dispatch) => {
export default compose( export default compose(
withJournal, withJournal,
withState('step', 'changeStep', 0), withState('step', 'changeStep', 0),
withState('initialValues', 'setInitialValues', {}),
withProps(({ location }) => { withProps(({ location }) => {
const params = new URLSearchParams(location.search) const params = new URLSearchParams(location.search)
const email = params.get('email') const email = params.get('email')
...@@ -66,11 +67,11 @@ export default compose( ...@@ -66,11 +67,11 @@ export default compose(
}), }),
lifecycle({ lifecycle({
componentDidMount() { componentDidMount() {
const { email, token } = this.props const { setInitialValues, token } = this.props
const encodedUri = `?email=${encodeURIComponent(email)}&token=${token}` const encodedUri = `?passwordResetToken=${token}`
request(`/users/invite${encodedUri}`) request(`/users/${encodedUri}`)
.then(res => { .then(res => {
this.setState({ initialValues: res }) setInitialValues(v => res.users[0])
}) })
.catch(err => { .catch(err => {
this.setState({ error: err.response }) this.setState({ error: err.response })
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment