Class: SecureLink::Authorize
- Inherits:
-
Object
- Object
- SecureLink::Authorize
- Defined in:
- lib/secure_link/authorize.rb
Instance Method Summary collapse
Instance Method Details
#authorized?(url, method = nil) ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/secure_link/authorize.rb', line 3 def (url, method = nil) return false unless url # Mailto link return true if url =~ /^mailto:/ method ||= (params[:method] || request.method) url_parts = URI::split(url.strip) path = url_parts[5] return true if current_user && (path) begin hash = Rails.application.routes.recognize_path(path, :method => method) return (path_from_hash(hash)) if hash rescue Exception => e end end |
#is_authorized?(resource) ⇒ Boolean
22 23 24 25 |
# File 'lib/secure_link/authorize.rb', line 22 def (resource) = Permission. .include?([resource, current_user.role]) end |