diff --git a/app/models/user.rb b/app/models/user.rb index 769bdcfa..dc0bb532 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -100,6 +100,10 @@ class User < ApplicationRecord end end + def can_subscribe? + active_until&.past? && !DawarichSettings.self_hosted? + end + def generate_subscription_token payload = { user_id: id, @@ -149,8 +153,4 @@ class User < ApplicationRecord ) end # rubocop:enable Metrics/MethodLength - - def can_subscribe? - active_until&.past? && !DawarichSettings.self_hosted? - end end diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 403712c3..0621b407 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -19,9 +19,9 @@ - <%# if user_signed_in? && current_user.can_subscribe? %> + <% if user_signed_in? && current_user.can_subscribe? %>
  • <%= link_to 'Subscribe', "#{ENV['SUBSCRIPTION_URL']}/auth/dawarich?token=#{current_user.generate_subscription_token}", class: 'btn btn-sm btn-success' %>
  • - <%# end %> + <% end %> <%= link_to 'Dawarich', root_path, class: 'btn btn-ghost normal-case text-xl'%> @@ -70,9 +70,9 @@