デバイス+ドアキーパーを使用するRailsアプリケーションがあります。ロール管理にもcancanを使用http://localhost:3000/oauth/applications/new
しています。アプリケーションでは、クライアントとシークレットIDを取得するためにアプリケーションを登録するために使用します。現在、すべてのユーザーがクライアントとシークレット ID を取得するために Web インターフェイスを介してアプリケーションを登録できます。管理者のみがアプリケーションを登録できるようにアクセスを制限する必要があります。
doorkeeper.rb
ファイルにいくつかのコードがありました
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
# admin_authenticator do
# # Put your admin authentication logic here.
# # Example implementation:
# Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
# end
私は以下のように試しましたが、うまくいきません...
admin_authenticator do
if(current_user)
current_user.role? :admin
else
redirect_to(new_user_session_url)
end
end
前もって感謝します......