有 2 个命名空间:
api/public
api/mobile
在公共控制器中创建具有适当范围的门卫授权。例如:
class API::Public::PostsController < ApplicationController
before_action -> { doorkeeper_authorize! :public }
def show
@post = Post.find(params[:id])
end
end
移动命名空间中的控制器继承自公共命名空间中的控制器。例如:
class API::Mobile::PostsController < API::Public::PostsController
skip_before_action :doorkeeper_authorize!
before_action -> { doorkeeper_authorize! :mobile }
end
所以这里的重点是功能是相同的,如果移动设备存在一些差异,那么可以在移动命名空间中覆盖操作。问题是这两个命名空间的范围不同,但是跳过了 doorkeeper_authorize!不起作用。
有没有办法解决这个问题?