Module: Bouncer::ControllerMixin

Defined in:
lib/bouncer-client/controller_mixin.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_activation!Object

Raises:



20
21
22
23
# File 'lib/bouncer-client/controller_mixin.rb', line 20

def authenticate_activation!
  authenticate_token!
  raise UnauthorizedError unless current_user.activation?
end

#authenticate_super_admin!Object

Raises:



15
16
17
18
# File 'lib/bouncer-client/controller_mixin.rb', line 15

def authenticate_super_admin!
  authenticate_user!
  raise UnauthorizedError unless current_user.user.super_admin?
end

#authenticate_token!Object



10
11
12
13
# File 'lib/bouncer-client/controller_mixin.rb', line 10

def authenticate_token!
  raise UnauthenticatedError unless Bouncer::Token.present? request
  raise UnauthenticatedError unless current_user.valid?
end

#authenticate_user!Object

Raises:



25
26
27
28
# File 'lib/bouncer-client/controller_mixin.rb', line 25

def authenticate_user!
  authenticate_token!
  raise UnauthorizedError unless current_user.user?
end

#current_userObject



5
6
7
8
# File 'lib/bouncer-client/controller_mixin.rb', line 5

def current_user
  return nil unless Bouncer::Token.present? request
  @token ||= Bouncer::Token.new(request.headers['authorization'])
end