Skip to content
Snippets Groups Projects
Select Git revision
  • 50d9421f200e9562bb805362b7a53505503d2234
  • main default protected
  • renovate/redis-5.x-lockfile
  • renovate/ruby
  • renovate/solid_queue-1.x-lockfile
  • renovate/selenium-webdriver-4.x-lockfile
  • renovate/icalendar-2.x-lockfile
  • renovate/debug-1.x-lockfile
  • renovate/turbo-rails-2.x-lockfile
  • renovate/gcr.io-kaniko-project-executor-1.x
  • eh22 protected
  • update-rubocop
12 results

users_controller.rb

Blame
  • users_controller.rb 849 B
    class UsersController < ApplicationController
      before_action :authenticate_user!, only: [ :update_theme ]
    
      def leaderboard
        @workload_data = User.leaderboard
      end
    
      def update_theme
        if current_user.present?
          # Ensure darkmode parameter is valid (light, dark)
          theme = params[:darkmode].to_s
          if [ "light", "dark" ].include?(theme)
            if current_user.update(darkmode: theme)
              render json: { success: true, theme: theme }, status: :ok
            else
              render json: { success: false, errors: current_user.errors.full_messages }, status: :unprocessable_entity
            end
          else
            render json: { success: false, error: "Invalid theme value" }, status: :bad_request
          end
        else
          render json: { success: false, error: "User not authenticated" }, status: :unauthorized
        end
      end
    end