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:
parent
0149ca4ea1
commit
d3d9af8bce
6 changed files with 37 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,6 +6,7 @@ class Demo::Generator
|
|||
end
|
||||
|
||||
def reset_and_clear_data!
|
||||
reset_settings!
|
||||
clear_data!
|
||||
create_user!
|
||||
|
||||
|
@ -14,6 +15,7 @@ class Demo::Generator
|
|||
|
||||
def reset_data!
|
||||
Family.transaction do
|
||||
reset_settings!
|
||||
clear_data!
|
||||
create_user!
|
||||
|
||||
|
@ -52,12 +54,17 @@ class Demo::Generator
|
|||
end
|
||||
|
||||
def clear_data!
|
||||
InviteCode.destroy_all
|
||||
User.find_by_email("user@maybe.local")&.destroy
|
||||
ExchangeRate.destroy_all
|
||||
Security.destroy_all
|
||||
Security::Price.destroy_all
|
||||
end
|
||||
|
||||
def reset_settings!
|
||||
Setting.destroy_all
|
||||
end
|
||||
|
||||
def create_user!
|
||||
family.users.create! \
|
||||
email: "user@maybe.local",
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<%
|
||||
header_title t(".title")
|
||||
%>
|
||||
|
||||
<% if self_hosted_first_login? %>
|
||||
<div class="fixed inset-0 w-full h-fit bg-gray-25 p-5 border-b border-alpha-black-200 flex flex-col gap-3 items-center text-center mb-12">
|
||||
<h2 class="font-bold text-xl"><%= t(".welcome_title") %></h2>
|
||||
<p class="text-gray-500 text-sm"><%= t(".welcome_body") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= styled_form_with model: @user, url: registration_path, class: "space-y-4" do |form| %>
|
||||
<%= auth_messages form %>
|
||||
<%= form.email_field :email, autofocus: false, autocomplete: "email", required: "required", placeholder: "you@example.com", label: true %>
|
||||
|
|
|
@ -14,3 +14,6 @@ en:
|
|||
success: You have signed up successfully.
|
||||
new:
|
||||
title: Create an account
|
||||
welcome_body: To get started, you must sign up for a new account. You will
|
||||
then be able to configure additional settings within the app.
|
||||
welcome_title: Welcome to Self Hosted Maybe!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue