Skip to content
Snippets Groups Projects
Unverified Commit f681999d authored by Hadi Cheaito's avatar Hadi Cheaito Committed by GitHub
Browse files

Change password feedback: old password (#4536)

* Change password feedback: old password

* rubo

* eslint
parent 5d889a1a
Branches
Tags
No related merge requests found
......@@ -367,7 +367,8 @@
},
"users": {
"invalid_invite": "Your invitation token is either invalid or incorrect. Please contact your administrator to receive a new one",
"email_exists": "An account under this email already exists. Please try again with another email"
"email_exists": "An account under this email already exists. Please try again with another email",
"old_password": "The current password you have entered is incorrect"
},
"rooms": {
"room_limit": "Room can not be created due to room limit being reached"
......
......@@ -66,7 +66,7 @@ module Api
# POST /api/v1/rooms.json
# Creates a room for the specified user if they are allowed to
def create
return render_error status: :bad_request, errors: 'RoomLimitError' unless PermissionsChecker.new(
return render_error status: :bad_request, errors: Rails.configuration.custom_error_msgs[:room_limit] unless PermissionsChecker.new(
permission_names: 'RoomLimit',
user_id: room_params[:user_id], current_user:, current_provider:
).call
......
......@@ -111,7 +111,10 @@ module Api
return render_error status: :bad_request if new_password.blank? || old_password.blank?
return render_error status: :bad_request unless current_user.authenticate old_password
unless current_user.authenticate old_password
return render_error status: :bad_request,
errors: Rails.configuration.custom_error_msgs[:incorrect_old_password]
end
current_user.update! password: new_password
render_data status: :ok
......
......@@ -12,8 +12,12 @@ export default function useChangePwd() {
onSuccess: () => {
toast.success(t('toast.success.user.password_updated'));
},
onError: () => {
onError: (err) => {
if (err.response.data.errors === 'IncorrectOldPassword') {
toast.error(t('toast.error.users.old_password'));
} else {
toast.error(t('toast.error.problem_completing_action'));
}
},
},
);
......
......@@ -29,7 +29,9 @@ module Greenlight
email_exists: 'EmailAlreadyExists',
record_invalid: 'RecordInvalid',
invite_token_invalid: 'InviteInvalid',
hcaptcha_invalid: 'HCaptchaInvalid'
hcaptcha_invalid: 'HCaptchaInvalid',
incorrect_old_password: 'IncorrectOldPassword',
room_limit: 'RoomLimitError'
}
ActiveModelSerializers.config.adapter = :json
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment