generators/oauth_provider/templates/oauth_token.rb in le1t0-oauth-plugin-0.3.14.001 vs generators/oauth_provider/templates/oauth_token.rb in le1t0-oauth-plugin-0.4.0.pre4.001
- old
+ new
@@ -1,10 +1,10 @@
class OauthToken < ActiveRecord::Base
belongs_to :client_application
belongs_to :user
validates_uniqueness_of :token
- validates_presence_of :client_application, :token, :secret
+ validates_presence_of :client_application, :token
before_validation_on_create :generate_keys
def invalidated?
invalidated_at != nil
end
@@ -22,10 +22,9 @@
end
protected
def generate_keys
- oauth_token = client_application.oauth_server.generate_credentials
- self.token = oauth_token[0][0,20]
- self.secret = oauth_token[1][0,40]
+ self.token = OAuth::Helper.generate_key(40)[0,40]
+ self.secret = OAuth::Helper.generate_key(40)[0,40]
end
end