1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Add basic self hosted onboarding (#1177)

* Add basic self hosted onboarding

* Lint fix

* Normalize translations
This commit is contained in:
Zach Gollwitzer 2024-09-13 17:24:19 -04:00 committed by GitHub
parent 0149ca4ea1
commit d3d9af8bce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 3 deletions

View file

@ -17,7 +17,11 @@ module Authentication
if user = User.find_by(id: session[:user_id])
Current.user = user
else
redirect_to new_session_url
if self_hosted_first_login?
redirect_to new_registration_url
else
redirect_to new_session_url
end
end
end
@ -36,4 +40,8 @@ module Authentication
def set_last_login_at
Current.user.update(last_login_at: DateTime.now)
end
def self_hosted_first_login?
Rails.application.config.app_mode.self_hosted? && User.count.zero?
end
end

View file

@ -7,6 +7,10 @@ module Invitable
private
def invite_code_required?
ENV["REQUIRE_INVITE_CODE"] == "true"
self_hosted? ? Setting.require_invite_for_signup : ENV["REQUIRE_INVITE_CODE"] == "true"
end
def self_hosted?
Rails.application.config.app_mode.self_hosted?
end
end

View file

@ -2,11 +2,15 @@ module SelfHostable
extend ActiveSupport::Concern
included do
helper_method :self_hosted?
helper_method :self_hosted?, :self_hosted_first_login?
end
private
def self_hosted?
Rails.configuration.app_mode.self_hosted?
end
def self_hosted_first_login?
self_hosted? && User.count.zero?
end
end