Module: Authenticator

Defined in:
lib/decoractors/authenticate.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(isAuthorized) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/decoractors/authenticate.rb', line 17

def authenticate isAuthorized
  lambda {|self_model, *args, &blk|
    puts "isAuthorized"
    # check authentication and authorization here, then return true/false
    if isAuthorized.call(*args, &blk)
      true
    else
      raise CommonError::PermissionDenied
    end
  }
end

#has_roles(roles) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/decoractors/authenticate.rb', line 5

def has_roles roles
  lambda {|*args, &blk|
    puts 'has_roles'
    check_role = true # check role here and return true/false
    if check_role
      true
    else
      false
    end
  }
end