Files
docuseal/app/controllers/profile_controller.rb
T

31 lines
814 B
Ruby
Raw Normal View History

2023-05-31 23:49:19 +03:00
# frozen_string_literal: true
class ProfileController < ApplicationController
2023-06-07 01:36:47 +03:00
def update_contact
if current_user.update(contact_params)
2023-06-07 12:04:11 +03:00
redirect_to settings_profile_index_path, notice: 'Contact information successfully updated'
2023-06-07 01:36:47 +03:00
else
2023-06-07 12:04:11 +03:00
render :index, status: :unprocessable_entity
2023-06-07 01:36:47 +03:00
end
2023-05-31 23:49:19 +03:00
end
2023-06-07 01:36:47 +03:00
def update_password
2023-06-07 12:04:11 +03:00
if current_user.update(password_params)
2023-06-07 01:36:47 +03:00
bypass_sign_in(current_user)
2023-06-07 12:04:11 +03:00
redirect_to settings_profile_index_path, notice: 'Password successfully changed'
2023-06-07 01:36:47 +03:00
else
2023-06-07 12:04:11 +03:00
render :index, status: :unprocessable_entity
2023-05-31 23:49:19 +03:00
end
end
private
2023-06-07 01:36:47 +03:00
def contact_params
2023-06-07 12:04:11 +03:00
params.require(:user).permit(:first_name, :last_name, :email, account_attributes: %i[name])
2023-06-07 01:36:47 +03:00
end
def password_params
2023-06-07 12:04:11 +03:00
params.require(:user).permit(:password, :password_confirmation)
2023-05-31 23:49:19 +03:00
end
end