Sha256: 1d203a389393e56c99cbcd942c0e98c33f56e88e75d4e69f8ee55a516eddfd7a

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

module Skydrive
  class User < ActiveRecord::Base
    include ActiveModel::ForbiddenAttributesProtection

    has_many :api_keys
    has_one :token

    validates :email, presence: true, uniqueness: true
    validates :username, presence: true, uniqueness: true
    validates :name, presence: true

    def session_api_key(params={})
      ApiKey.create(
        user_id: self.id,
        scope: 'session',
        init_params: params.to_json
      )
    end

    def cleanup_api_keys
      api_keys.inactive.each(&:destroy)
    end

    def valid_skydrive_token?
      !self.token.nil? && self.token.is_valid?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lti_skydrive-0.1.1 app/models/skydrive/user.rb