allow to clone templates to linked accounts

This commit is contained in:
Pete Matsyburka
2024-02-15 11:13:05 +02:00
parent 008b83119d
commit df7aa59f6f
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -51,7 +51,7 @@ class TemplatesController < ApplicationController
@template.folder = TemplateFolders.find_or_create_by_name(current_user, params[:folder_name])
end
if params[:account_id].present? && current_account.linked_accounts.exists?(id: params[:account_id])
if params[:account_id].present? && authorized_clone_account_id?(params[:account_id])
@template.account_id = params[:account_id]
@template.folder = @template.account.default_template_folder
else
@@ -86,6 +86,10 @@ class TemplatesController < ApplicationController
private
def authorized_clone_account_id?(account_id)
true_user.account_id.to_s == account_id.to_s || true_user.account.linked_accounts.exists?(id: account_id)
end
def maybe_redirect_to_template(template)
if template.account == current_account
redirect_to(edit_template_path(@template))