mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
37 lines
790 B
Ruby
37 lines
790 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SettingsController < ApplicationController
|
|
before_action :authenticate_user!
|
|
|
|
def index
|
|
end
|
|
|
|
def update
|
|
current_user.update(settings: settings_params)
|
|
|
|
flash.now[:notice] = 'Settings updated'
|
|
|
|
redirect_to settings_path, notice: 'Settings updated'
|
|
end
|
|
|
|
def theme
|
|
current_user.update(theme: params[:theme])
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
end
|
|
|
|
def generate_api_key
|
|
current_user.update(api_key: SecureRandom.hex)
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
end
|
|
|
|
private
|
|
|
|
def settings_params
|
|
params.require(:settings).permit(
|
|
:meters_between_routes, :minutes_between_routes, :fog_of_war_meters,
|
|
:time_threshold_minutes, :merge_threshold_minutes, :route_opacity
|
|
)
|
|
end
|
|
end
|