Skip to content

Instantly share code, notes, and snippets.

@glaucocustodio
Created July 4, 2013 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glaucocustodio/5929646 to your computer and use it in GitHub Desktop.
Save glaucocustodio/5929646 to your computer and use it in GitHub Desktop.
Doorkepper and CanCan
# routes
use_doorkeeper do
controllers :applications => 'custom_applications',
:authorized_applications => 'custom_authorized_applications',
:authorizations => 'custom_authorizations'
end
# application
config.to_prepare do
# Only Applications list
Doorkeeper::ApplicationsController.layout "application"
# Only Authorization endpoint
Doorkeeper::AuthorizationsController.layout "application"
# Only Authorized Applications
Doorkeeper::AuthorizedApplicationsController.layout "application"
end
class CustomAuthorizationsController < Doorkeeper::AuthorizationsController
include BeforeAction
before_action :foo, :bar
end
class CustomAuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
include BeforeAction
# only users signed in with Devise can see authorized apps
before_action :authenticate_user!, :foo, :bar
# CanCan, the below line generate error, I cant use CanCan?!
# authorize_resource
end
class CustomApplicationsController < Doorkeeper::ApplicationsController
include BeforeAction
# CanCan, the below line generate error, I cant use CanCan?!
#authorize_resource
before_action :authenticate_user!, :foo, :bar
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment