app/models/access_grant.rb in doorkeeper-0.2.0 vs app/models/access_grant.rb in doorkeeper-0.3.0

- old
+ new

@@ -1,45 +1,31 @@ class AccessGrant < ActiveRecord::Base - include Doorkeeper::OAuth::RandomString + include Doorkeeper::OAuth::Helpers + include Doorkeeper::Models::Expirable + include Doorkeeper::Models::Revocable - set_table_name :oauth_access_grants + self.table_name = :oauth_access_grants belongs_to :application validates :resource_owner_id, :application_id, :token, :expires_in, :redirect_uri, :presence => true before_validation :generate_token, :on => :create - def expired? - expires_in.present? && Time.now > expired_time - end - def accessible? !expired? && !revoked? end - def revoke - update_attribute :revoked_at, DateTime.now - end - - def revoked? - revoked_at.present? - end - def scopes - self[:scopes].split(" ").map(&:to_sym) + self[:scopes].split(" ").map(&:to_sym) if self[:scopes] end def scopes_string self[:scopes] end private - def expired_time - self.created_at + expires_in.seconds - end - def generate_token - self.token = unique_random_string_for(:token) + self.token = UniqueToken.generate_for :token, self.class end end