moved the monkey patching to a model, need to do a couple of validations
This commit is contained in:
parent
b3cee70ead
commit
75a1012c1c
3 changed files with 25 additions and 13 deletions
|
|
@ -81,16 +81,3 @@ class AuthorizationsController < ApplicationController
|
||||||
!OAuth2::Provider.client_class.exists?(:nonce => nonce)
|
!OAuth2::Provider.client_class.exists?(:nonce => nonce)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
OAuth2::Provider.client_class.instance_eval do
|
|
||||||
def self.create_or_reset_from_manifest! manifest
|
|
||||||
if obj = find_by_name(manifest['name'])
|
|
||||||
obj.oauth_identifier = OAuth2::Provider::Random.base62(16)
|
|
||||||
obj.oauth_secret = OAuth2::Provider::Random.base62(32)
|
|
||||||
obj.save!
|
|
||||||
obj
|
|
||||||
else
|
|
||||||
create!(manifest)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
||||||
12
app/models/oauth2_provider_models_activerecord_client.rb
Normal file
12
app/models/oauth2_provider_models_activerecord_client.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
class OAuth2::Provider::Models::ActiveRecord::Client
|
||||||
|
def self.create_or_reset_from_manifest! manifest
|
||||||
|
if obj = find_by_name(manifest['name'])
|
||||||
|
obj.oauth_identifier = OAuth2::Provider::Random.base62(16)
|
||||||
|
obj.oauth_secret = OAuth2::Provider::Random.base62(32)
|
||||||
|
obj.save!
|
||||||
|
obj
|
||||||
|
else
|
||||||
|
create!(manifest)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
#
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe OAuth2::Provider::Models::ActiveRecord::Client do
|
||||||
|
#TODO
|
||||||
|
describe 'validations'do
|
||||||
|
it 'is pending for now'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Reference in a new issue