Skip to content

Commit

Permalink
Create trial keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Aug 28, 2024
1 parent 22aebdc commit 628bb02
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/api_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 628bb02

Please sign in to comment.