- has_many :tokens, :class_name => "OauthToken"
- validates_presence_of :name, :url, :key, :secret
- validates_uniqueness_of :key
- before_validation_on_create :generate_keys
-
+ has_many :tokens, :class_name => "OauthToken", :dependent => :delete_all
+ has_many :access_tokens
+ has_many :oauth2_verifiers
+ has_many :oauth_tokens
+
+ validates :key, :presence => true, :uniqueness => true
+ validates :name, :url, :secret, :presence => true
+ validates :url, :format => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
+ validates :support_url, :callback_url, :allow_blank => true, :format => %r{\Ahttp(s?)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!\-/]))?}i
+
+ before_validation :generate_keys, :on => :create
+
+ attr_accessor :token_callback_url
+