mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
* 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.
26 lines
597 B
Ruby
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
|