Files
docuseal/app/controllers/profile_controller.rb
T

37 lines
873 B
Ruby
Raw Normal View History

2023-05-31 23:49:19 +03:00
# frozen_string_literal: true
class ProfileController < ApplicationController
2023-09-17 00:45:57 +03:00
before_action do
authorize!(:manage, current_user)
end
def index; end
2023-06-07 01:36:47 +03:00
def update_contact
if current_user.update(contact_params)
2024-09-18 19:47:47 +03:00
redirect_to settings_profile_index_path, notice: I18n.t('contact_information_has_been_update')
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)
2024-09-18 19:47:47 +03:00
redirect_to settings_profile_index_path, notice: I18n.t('password_has_been_changed')
else
render :index, status: :unprocessable_entity
end
end
2023-05-31 23:49:19 +03:00
private
2023-06-07 01:36:47 +03:00
def contact_params
2023-06-30 01:26:13 +03:00
params.require(:user).permit(:first_name, :last_name, :email)
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