Created
June 5, 2013 21:59
-
-
Save kidpollo/5717664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module V1 | |
class BaseController < ApplicationController | |
include V1::ResponseMetaData | |
include V1::ErrorHandling | |
include V1::ReadOnly | |
include Pundit | |
rescue_from Pundit::NotAuthorizedError, with: :render_401 | |
rescue_from ActiveRecord::RecordInvalid, :with => :render_422 | |
def warden | |
env['warden'] | |
end | |
def current_consumer | |
@current_consumer ||= (warden.authenticate! scope: current_community) | |
end | |
helper_method :current_consumer | |
def current_scope | |
@current_scope ||= begin | |
current_consumer.scope | |
end | |
end | |
helper_method :current_scope | |
def current_user | |
current_consumer.user | |
end | |
helper_method :current_user | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment