|
12345678910111213141516171819202122232425262728293031323334 |
- require 'eaal'
-
- class User < ActiveRecord::Base
- has_secure_password
- alias_attribute :admin?, :is_admin
-
- def char_names
- ensure_api_user
- begin
- @api.Characters.characters.map { |char| char.name }
- rescue EAAL::EAALError
- []
- end
- end
-
- def in_corp?
- member_of? AdminSettings.get(:corp_id).to_i
- end
-
- def member_of?(corp_id)
- ensure_api_user
- @api.scope = 'char'
- begin
- @api.CharacterSheet(names: name).corporationID.to_i == corp_id
- rescue EAAL::EAALError
- false
- end
- end
-
- private
- def ensure_api_user
- @api ||= EAAL::API.new(api_key, api_verify)
- end
- end
|