Skip to content
Snippets Groups Projects
Select Git revision
  • 0997843257f080946778d8d7851307687f30a1c0
  • main default protected
  • fix-search
  • network-typo-shielded-remmediation
  • rework-photopolicy-social-media
  • pr-47
  • isdn
7 results

styleguide.md

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