Sha256: 5c4cc5d7ad3ca6a896b147d0ba6dad325034971b1921e71e1250952a234d6085

Contents?: true

Size: 768 Bytes

Versions: 5

Compression:

Stored size: 768 Bytes

Contents

class Devise::Oauth2::Client < ActiveRecord::Base

  has_many :access_tokens
  has_many :refresh_tokens
  has_many :authorization_codes

  before_validation :init_identifier, :on => :create, :unless => :identifier?
  before_validation :init_secret, :on => :create, :unless => :secret?
  validates :identifier, :presence => true, :uniqueness => true

  serialize :default_permissions

  def default_permissions=(permissions)
    super(permissions) if permissions.is_a? Array
    permissions = permissions.split(/[,\s\n\b\t]/).keep_if { |x| !x.blank? } if permissions.is_a? String
    super(permissions)
  end

  private

  def init_identifier
    self.identifier = Devise::Oauth2.random_id
  end

  def init_secret
    self.secret = Devise::Oauth2.random_id
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise_oauth2_rails4-1.1.7 app/models/devise/oauth2/client.rb
devise_oauth2_rails4-1.1.6 app/models/devise/oauth2/client.rb
devise_oauth2_rails4-1.1.5 app/models/devise/oauth2/client.rb
devise_oauth2_rails4-1.1.4 app/models/devise/oauth2/client.rb
devise_oauth2_rails4-1.1.3 app/models/devise/oauth2/client.rb