Skip to content

Commit

Permalink
Remove .make_first_user_admin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Feb 16, 2025
1 parent 693bc98 commit d839c96
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ jobs:
LOGIN_EXPIRY: '86400' # 1 day
LOGIN_IDLE_TIMEOUT: '1800' # 30 minutes
LOGO_URL: /logo.png
MAKE_FIRST_USER_ADMIN: 'true'
NAME: penny
PASSWORD_MIN_LENGTH: '4'
PASSWORD_REQUIRE_LOWERCASE: 'false'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ jobs:
LOGIN_EXPIRY: '86400' # 1 day
LOGIN_IDLE_TIMEOUT: '1800' # 30 minutes
LOGO_URL: /logo.png
MAKE_FIRST_USER_ADMIN: 'true'
NAME: penny
PASSWORD_MIN_LENGTH: '4'
PASSWORD_REQUIRE_LOWERCASE: 'false'
Expand Down
3 changes: 0 additions & 3 deletions config/app.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ App.configure do |settings|
settings.email_from = ENV["EMAIL_FROM"]
settings.email_reply_to = ENV["EMAIL_REPLY_TO"]

settings.make_first_user_admin = Bool.adapter
.parse!(ENV["MAKE_FIRST_USER_ADMIN"])

settings.keep_bearer_logins_for = Time::Span.new(
days: ENV["KEEP_BEARER_LOGINS_DAYS"].to_i
)
Expand Down
1 change: 0 additions & 1 deletion fly.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ swap_size_mb = 256
LOGIN_EXPIRY = '86400' # 1 day
LOGIN_IDLE_TIMEOUT = '1800' # 30 minutes
LOGO_URL = '/logo.png'
MAKE_FIRST_USER_ADMIN = 'false'
NAME = 'Penny (staging)'
PASSWORD_MIN_LENGTH = '4'
PASSWORD_REQUIRE_LOWERCASE = 'false'
Expand Down
1 change: 0 additions & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ swap_size_mb = 256
LOGIN_EXPIRY = '86400' # 1 day
LOGIN_IDLE_TIMEOUT = '1800' # 30 minutes
LOGO_URL = '/logo.png'
MAKE_FIRST_USER_ADMIN = 'false'
NAME = 'Penny'
PASSWORD_MIN_LENGTH = '12'
PASSWORD_REQUIRE_LOWERCASE = 'true'
Expand Down
7 changes: 0 additions & 7 deletions sample.env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

lucky_env: development # Set to `production` in production

# Set this to `"true"` to make the first user
# to register an "admin"
#
# After the first user is registered, set this
# back to `"false"` and restart the app process
make_first_user_admin: 'false'

name: My App
url: http://localhost:5000

Expand Down
1 change: 0 additions & 1 deletion src/app_settings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module App
setting keep_logins_for : Time::Span
setting keep_password_resets_for : Time::Span
setting logo_url : String
setting make_first_user_admin : Bool
setting name : String
setting timezone : Time::Location?
setting url : String
Expand Down
3 changes: 2 additions & 1 deletion src/operations/register_current_user.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class RegisterCurrentUser < User::SaveOperation
include Mixins::ValidateNotPwned
include Shield::SendWelcomeEmail

# Makes first user admin
private def set_level
if App.settings.make_first_user_admin && UserQuery.new.none?
if UserQuery.new.none?
level.value = UserLevel.new(:admin)
else
level.value = UserLevel.new(:author)
Expand Down

0 comments on commit d839c96

Please sign in to comment.