Files
docuseal/app/controllers/profile_controller.rb
T

33 lines
794 B
Ruby
Raw Normal View History

2023-05-31 23:49:19 +03:00
# frozen_string_literal: true
class ProfileController < ApplicationController
def index; end
2023-06-07 01:36:47 +03:00
def update_contact
if current_user.update(contact_params)
2023-06-30 01:26:13 +03:00
redirect_to settings_profile_index_path, notice: 'Contact information has been 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-30 01:26:13 +03:00
redirect_to settings_profile_index_path, notice: '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