mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
* fix: Only admins can generate invite codes * fix: raise error if user is not an admin when creating invite codesss
19 lines
453 B
Ruby
19 lines
453 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
|
|
|
|
private
|
|
|
|
def ensure_self_hosted
|
|
redirect_to root_path unless self_hosted?
|
|
end
|
|
end
|