2024-05-18 06:13:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class SettingsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
2024-06-20 17:57:00 -04:00
|
|
|
def index
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
current_user.update(settings: settings_params)
|
|
|
|
|
|
|
|
|
|
flash.now[:notice] = 'Settings updated'
|
|
|
|
|
|
|
|
|
|
redirect_to settings_path, notice: 'Settings updated'
|
|
|
|
|
end
|
|
|
|
|
|
2024-05-18 06:13:29 -04:00
|
|
|
def theme
|
|
|
|
|
current_user.update(theme: params[:theme])
|
|
|
|
|
|
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
|
|
|
end
|
2024-05-25 07:57:50 -04:00
|
|
|
|
|
|
|
|
def generate_api_key
|
|
|
|
|
current_user.update(api_key: SecureRandom.hex)
|
|
|
|
|
|
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
|
|
|
end
|
2024-06-20 17:57:00 -04:00
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def settings_params
|
2024-06-25 16:30:11 -04:00
|
|
|
params.require(:settings).permit(
|
|
|
|
|
:meters_between_routes, :minutes_between_routes, :fog_of_war_meters
|
|
|
|
|
)
|
2024-06-20 17:57:00 -04:00
|
|
|
end
|
2024-05-18 06:13:29 -04:00
|
|
|
end
|