A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
592 B

  1. require 'eaal'
  2. class User < ActiveRecord::Base
  3. has_secure_password
  4. alias_attribute :admin?, :is_admin
  5. alias_attribute :corp?, :is_corp
  6. def char_names
  7. ensure_api_user
  8. begin
  9. @api.Characters.characters.map { |char| char.name }
  10. rescue EAAL::EAALError
  11. []
  12. end
  13. end
  14. def member_of?(corp_id)
  15. ensure_api_user
  16. @api.scope = 'char'
  17. begin
  18. @api.CharacterSheet(names: name).corporationID.to_i == corp_id
  19. rescue EAAL::EAALError
  20. false
  21. end
  22. end
  23. private
  24. def ensure_api_user
  25. @api ||= EAAL::API.new(api_key, api_verify)
  26. end
  27. end