Files
wowbug/app/controllers/admins_controller.rb
T
robbiepaul b66ee00361
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
Update
2026-04-29 00:57:55 +01:00

39 lines
881 B
Ruby

class AdminsController < ApplicationController
PASSWORD_PARTS = %w[GEAR AXLE TURBO PARK].freeze
def show
@unlocked = admin_unlocked?
end
def create
if submitted_password == admin_password
session[:admin_unlocked] = true
redirect_to admin_path, notice: "Admin Panel Unlocked"
else
session[:admin_unlocked] = false
@unlocked = false
flash.now[:alert] = "That passphrase did not unlock anything. Check the stock page again."
render :show, status: :unprocessable_entity
end
end
def destroy
session.delete(:admin_unlocked)
redirect_to admin_path, notice: "Admin session cleared."
end
private
def admin_password
PASSWORD_PARTS.join("-")
end
def admin_unlocked?
session[:admin_unlocked] == true
end
def submitted_password
params.fetch(:password, "").upcase.gsub(/\s+/, "")
end
end