2015-12-17 11:49:40 +00:00
|
|
|
class ExternalCredential < ApplicationModel
|
|
|
|
include ApplicationLib
|
|
|
|
|
2015-12-15 10:15:27 +00:00
|
|
|
validates :name, presence: true
|
|
|
|
store :credentials
|
2015-12-17 11:49:40 +00:00
|
|
|
|
|
|
|
def self.app_verify(params)
|
|
|
|
backend = load_backend(params[:provider])
|
|
|
|
backend.app_verify(params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.request_account_to_link(provider, callback)
|
|
|
|
backend = load_backend(provider)
|
|
|
|
backend.request_account_to_link(callback)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.link_account(provider, request_token, params)
|
|
|
|
backend = load_backend(provider)
|
|
|
|
backend.link_account(request_token, params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.load_backend(provider)
|
|
|
|
adapter = "ExternalCredential::#{provider.camelcase}"
|
|
|
|
require "#{adapter.to_filename}"
|
|
|
|
load_adapter(adapter)
|
|
|
|
end
|
|
|
|
|
2015-12-15 10:15:27 +00:00
|
|
|
end
|