rubocop + allow unauthed users to see all users

This commit is contained in:
Devin Howard 2016-10-04 22:51:21 +08:00
parent 2eae89a6b7
commit df29e48d8c
4 changed files with 9 additions and 8 deletions

View file

@ -5,7 +5,7 @@ module Api
def current def current
@user = current_user @user = current_user
authorize @user authorize @user
return show show # delegate to the normal show function
end end
private private

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class MetacodePolicy < ApplicationPolicy class MetacodePolicy < ApplicationPolicy
def index? def index?
true true

View file

@ -1,14 +1,15 @@
# frozen_string_literal: true
class UserPolicy < ApplicationPolicy class UserPolicy < ApplicationPolicy
def index? def index?
user.present? true
end end
def show? def show?
user.present? true
end end
def create? def create?
fail 'Create should be handled by Devise' raise 'Create should be handled by Devise'
end end
def update? def update?
@ -34,8 +35,7 @@ class UserPolicy < ApplicationPolicy
class Scope < Scope class Scope < Scope
def resolve def resolve
return scope.all if user.present? scope.all
scope.none
end end
end end
end end

View file

@ -8,7 +8,7 @@ module Api
:generation :generation
attribute :is_admin, attribute :is_admin,
if: -> { scope[:show_is_admin] && scope[:current_user] == object } if: -> { scope[:show_is_admin] && scope[:current_user] == object }
def avatar def avatar
object.image.url(:sixtyfour) object.image.url(:sixtyfour)