Files
sure/app/controllers/invite_codes_controller.rb
Mark Hendriksen f3fecc40ba Add ability to delete invite codes (#153)
* Add ability to delete invite codes

Implemented destroy action in InviteCodesController and updated routes to support invite code deletion. Updated invite code partial to include a delete button and improved styling. Also refactored the generate tokens button in invite code settings to use DS::Button.

* Show advanced settings only to admin users

Updated the settings navigation to display the advanced section only for admin users. Also improved handling of hidden elements in the invite code CSS.
2025-09-22 09:29:23 +02:00

26 lines
597 B
Ruby

class InviteCodesController < ApplicationController
before_action :ensure_self_hosted
def index
@invite_codes = InviteCode.all
end
def create
raise StandardError, "You are not allowed to generate invite codes" unless Current.user.admin?
InviteCode.generate!
redirect_back_or_to invite_codes_path, notice: "Code generated"
end
def destroy
code = InviteCode.find(params[:id])
code.destroy
redirect_back_or_to invite_codes_path, notice: "Code deleted"
end
private
def ensure_self_hosted
redirect_to root_path unless self_hosted?
end
end