Skip to content

Commit

Permalink
Fix validation issue when creating a new user and forgetting the pass…
Browse files Browse the repository at this point in the history
…word (#2205)
  • Loading branch information
Pierre-Gilles authored Jan 23, 2025
1 parent 6829fac commit 110db18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions front/src/actions/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function createActions(store) {
errored = true;
errors.email = true;
}
if (user.password) {
if (user.password !== undefined) {
if (user.password !== user.passwordRepeat) {
errored = true;
errors.passwordRepeat = true;
Expand Down Expand Up @@ -157,7 +157,7 @@ function createActions(store) {
const data = Object.assign({}, state.newUser);
const errored = actions.validateUser(state);
if (errored) {
throw new Error();
throw new Error('VALIDATION_FAILED');
}
data.birthdate = new Date(data.birthdateYear, data.birthdateMonth - 1, data.birthdateDay);
delete data.birthdateYear;
Expand All @@ -177,7 +177,9 @@ function createActions(store) {
} catch (e) {
console.error(e);
const status = get(e, 'response.status');
if (status === 409) {
if (e.message === 'VALIDATION_FAILED') {
console.error('User validation failed');
} else if (status === 409) {
store.setState({
createUserError: e.response.data,
createUserStatus: RequestStatus.ConflictError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SettingsUsers extends Component {
firstname: '',
lastname: '',
selector: '',
password: '',
email: '',
language: 'en',
role: 'admin',
Expand Down

0 comments on commit 110db18

Please sign in to comment.