title: Rails 3: How to restrict access to the web interface for adding oauth authorized applications using Doorkeeper gem
body: <p>I have a Rails Application Which uses Device + doorkeeper.I am also using cancan for Role Management.In my application i uses <code>http://localhost:3000/oauth/applications/new</code> for registering my application for getting Client and Secret id.
  Currently any user can register application through web interface for getting client and secret id ,i need to restrict access so that only admin can register Application.</p>
  
  <p>I saw some code in <code>doorkeeper.rb</code> file</p>
  
  <pre><code># 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
  </code></pre>
  
  <p>I tried like below ,but not working...</p>
  
  <pre><code>admin_authenticator do
    if(current_user)
      current_user.role? :admin
    else
      redirect_to(new_user_session_url)
    end
  end
  </code></pre>
  
  <p>Thanks in advance......</p>