mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
enhancement: Current password confirmation in change password (#2108)
* add current password field in change password form * locale changes * chore: update password API * chore: rubocop fixes * replace currentPassword with current_password * code cleanup * replace input with woot-input * code cleanup Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -39,7 +39,7 @@ RSpec.describe 'Profile API', type: :request do
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
let(:agent) { create(:user, account: account, role: :agent) }
|
||||
let(:agent) { create(:user, password: 'Test123!', account: account, role: :agent) }
|
||||
|
||||
it 'updates the name & email' do
|
||||
new_email = Faker::Internet.email
|
||||
@@ -56,13 +56,23 @@ RSpec.describe 'Profile API', type: :request do
|
||||
expect(agent.email).to eq(new_email)
|
||||
end
|
||||
|
||||
it 'updates the password' do
|
||||
it 'updates the password when current password is provided' do
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { password: 'test123', password_confirmation: 'test123' } },
|
||||
params: { profile: { current_password: 'Test123!', password: 'test123', password_confirmation: 'test123' } },
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(agent.reload.valid_password?('test123')).to eq true
|
||||
end
|
||||
|
||||
it 'throws error when current password provided is invalid' do
|
||||
put '/api/v1/profile',
|
||||
params: { profile: { current_password: 'Test', password: 'test123', password_confirmation: 'test123' } },
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
end
|
||||
|
||||
it 'updates avatar' do
|
||||
|
||||
Reference in New Issue
Block a user