Extract saas helpers into a concern

This commit is contained in:
Stanko K.R.
2025-11-06 14:29:18 +01:00
parent 2fee728392
commit bbe74966a1
4 changed files with 14 additions and 2 deletions
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
include Authorization
include CurrentRequest, CurrentTimezone, SetPlatform
include TurboFlash, ViewTransitions
include Saas
stale_when_importmap_changes
allow_browser versions: :modern
+11
View File
@@ -0,0 +1,11 @@
module Saas
extend ActiveSupport::Concern
included do
helper_method :signups_allowed?
end
def signups_allowed?
defined?(Signup) && defined?(saas)
end
end
+1 -1
View File
@@ -18,7 +18,7 @@ class SessionsController < ApplicationController
magic_link = identity.send_magic_link
flash[:magic_link_code] = magic_link&.code if Rails.env.development?
redirect_to session_magic_link_path
elsif defined?(Signup) && defined?(saas)
elsif signups_allowed?
Signup.new(email_address: email_address).create_identity
session[:return_to_after_authenticating] = saas.new_signup_membership_path
redirect_to session_magic_link_path
+1 -1
View File
@@ -24,7 +24,7 @@
<p class="margin-none-block-start">You dont have any Fizzy accounts.</p>
<% end %>
<% if defined?(saas) %>
<% if signups_allowed? %>
<div class="margin-block-start">
<%= link_to saas.new_signup_membership_path, class: "btn btn--plain txt-link center txt-small", data: { turbo_prefetch: false } do %>
<span>Sign up for a new Fizzy account</span>