add cancan for authorization
This commit is contained in:
@@ -3,13 +3,29 @@
|
||||
class DashboardController < ApplicationController
|
||||
skip_before_action :authenticate_user!, only: %i[index]
|
||||
|
||||
before_action :maybe_redirect_product_url
|
||||
before_action :maybe_render_landing
|
||||
|
||||
load_and_authorize_resource :template, parent: false
|
||||
|
||||
def index
|
||||
return redirect_to Docuseal::PRODUCT_URL, allow_other_host: true if Docuseal.multitenant? && !signed_in?
|
||||
return render 'pages/landing' unless signed_in?
|
||||
@templates = @templates.active.preload(:author).order(id: :desc)
|
||||
@templates = Templates.search(@templates, params[:q])
|
||||
|
||||
templates = current_account.templates.active.preload(:author).order(id: :desc)
|
||||
templates = Templates.search(templates, params[:q])
|
||||
@pagy, @templates = pagy(@templates, items: 12)
|
||||
end
|
||||
|
||||
@pagy, @templates = pagy(templates, items: 12)
|
||||
private
|
||||
|
||||
def maybe_redirect_product_url
|
||||
return if !Docuseal.multitenant? || signed_in?
|
||||
|
||||
redirect_to Docuseal::PRODUCT_URL, allow_other_host: true
|
||||
end
|
||||
|
||||
def maybe_render_landing
|
||||
return if signed_in?
|
||||
|
||||
render 'pages/landing'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user