diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index 8c4d36984..baad692f0 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -24,7 +24,13 @@ def create # For the time being limit users to only creating one API key if user.api_keys.empty? - user.api_keys.create! + if Flipper.enabled?(:api_keys_in_profile, current_user) + # Create a trial key which automatically expires and has a low daily limit + # TODO: Extract this + user.api_keys.create!(daily_limit: ApiKey.default_daily_limit_trial, expires_at: ApiKey.default_trial_duration_days.days.from_now) + else + user.api_keys.create! + end redirect_to redirect_url, notice: t(".success") else # This is a terrible way of showing an error but it's not likely to happen so I'm not going to worry about that