- before_validation_on_create :generate_keys
-
- def self.verify_request(request, options = {}, &block)
- begin
- signature = OAuth::Signature.build(request, options, &block)
- logger.info "Signature Base String: #{signature.signature_base_string}"
- logger.info "Consumer: #{signature.send :consumer_key}"
- logger.info "Token: #{signature.send :token}"
- return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
- value = signature.verify
- logger.info "Signature verification returned: #{value.to_s}"
- value
- rescue OAuth::Signature::UnknownSignatureMethod => e
- logger.info "ERROR"+e.to_s
- false
+ validates_format_of :url, :with => /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i
+ validates_format_of :support_url, :with => /\Ahttp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i, :allow_blank => true
+ validates_format_of :callback_url, :with => /\A[a-z][a-z0-9.+-]*:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i, :allow_blank => true
+
+ before_validation :generate_keys, :on => :create
+
+ attr_accessor :token_callback_url
+
+ def self.find_token(token_key)
+ token = OauthToken.find_by_token(token_key, :include => :client_application)
+ if token && token.authorized?
+ token
+ else
+ nil