diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 110f579..3cc7b5f 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,16 +1,16 @@ class HomeController < ApplicationController + after_action :verify_authorized + def index + authorize User if user_signed_in? name = current_user.name(false) - if name.nil? || name == "" then + if name.blank? redirect_to edit_user_registration_path else redirect_to projects_url end end end - - def about_us - end end diff --git a/app/policies/home_policy.rb b/app/policies/home_policy.rb new file mode 100644 index 0000000..dbb3d9a --- /dev/null +++ b/app/policies/home_policy.rb @@ -0,0 +1,19 @@ +class UserPolicy < ApplicationPolicy + attr_reader :user + + def initialize(user, users) + @user = user + @users = users + end + + def index? + true + end + + class Scope < Scope + def resolve + scope.where(organisation_id: user.organisation_id) + end + end + +end \ No newline at end of file