Refactor user settings
All checks were successful
continuous-integration/drone/push Build is passing

Use resources instead of custom controllers, following the Rails way
and making things much cleaner in the process.
This commit is contained in:
Râu Cao
2023-04-03 13:19:07 +02:00
parent 6f2160b479
commit 7f77ad5528
11 changed files with 92 additions and 96 deletions

View File

@@ -1,13 +0,0 @@
class Settings::AccountController < SettingsController
def index
end
def reset_password
current_user.send_reset_password_instructions
sign_out current_user
msg = "We have sent you an email with a link to reset your password."
redirect_to check_your_email_path, notice: msg
end
end

View File

@@ -1,11 +0,0 @@
class Settings::ProfileController < SettingsController
def index
@user = current_user
end
def update
end
end

View File

@@ -1,13 +1,37 @@
class SettingsController < ApplicationController
before_action :require_user_signed_in
before_action :set_current_section
before_action :authenticate_user!
before_action :set_main_nav_section
before_action :set_settings_section, only: ['show', 'update']
def index
redirect_to setting_path(:profile)
end
def show
@user = current_user
end
def update
end
def reset_password
current_user.send_reset_password_instructions
sign_out current_user
msg = "We have sent you an email with a link to reset your password."
redirect_to check_your_email_path, notice: msg
end
private
def set_current_section
def set_main_nav_section
@current_section = :settings
end
def set_settings_section
@settings_section = params[:section]
unless [:profile, :account].include?(@settings_section.to_sym)
redirect_to setting_path(:profile)
end
end
end