FIX bug
This commit is contained in:
parent
4642b1250f
commit
2199258f8e
|
@ -3,10 +3,9 @@ class Oauth::EducoderController < Oauth::BaseController
|
|||
begin
|
||||
login = params[:login]
|
||||
callback_url = params[:callback_url]
|
||||
oauth_token = params[:key]
|
||||
raw_pay_load = params[:raw_pay_load]
|
||||
token = params[:token]
|
||||
|
||||
::OauthEducoderForm.new({login: login, oauth_token: oauth_token, callback_url: callback_url, raw_pay_load: raw_pay_load}).validate!
|
||||
::OauthEducoderForm.new({login: login, token: token, callback_url: callback_url}).validate!
|
||||
|
||||
open_user= OpenUser::Educoder.find_by(uid: login)
|
||||
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
class OauthEducoderForm
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :login, :oauth_token, :callback_url, :raw_pay_load
|
||||
attr_accessor :login, :token, :callback_url
|
||||
|
||||
validates :login, presence: true
|
||||
validates :oauth_token, presence: true
|
||||
validates :token, presence: true
|
||||
validates :callback_url, presence: true
|
||||
validates :raw_pay_load, presence: true
|
||||
|
||||
validate :check_oauth_token!
|
||||
validate :check_callback_url!
|
||||
valitate :check_auth!
|
||||
|
||||
def checke_raw_pay_load!
|
||||
def check_auth!
|
||||
secret = OauthEducoder.config[:access_key_secret]
|
||||
|
||||
before_raw_pay_load = "#{login}#{secret}#{Time.now.to_i/60-1}"
|
||||
now_raw_pay_load = "#{login}#{secret}#{Time.now.to_i/60-1}"
|
||||
now_raw_pay_load = "#{login}#{secret}#{Time.now.to_i/60}"
|
||||
|
||||
if raw_pay_load != Digest::SHA1.hexdigest(now_raw_pay_load) || raw_pay_load != Digest::SHA1.hexdigest(before_raw_pay_load)
|
||||
if token != Digest::SHA1.hexdigest(now_raw_pay_load) || token != Digest::SHA1.hexdigest(before_raw_pay_load)
|
||||
raise '你的请求无效值无效.'
|
||||
end
|
||||
end
|
||||
|
||||
def checke_raw_pay_load!
|
||||
secret = OauthEducoder.config[:access_key_secret]
|
||||
raise 'oauth_token值无效.' if oauth_token != secret
|
||||
end
|
||||
|
||||
def check_callback_url!
|
||||
request_host = URI.parse(callback_url).host
|
||||
callback_url = OauthEducoder.config[:callback_url_host]
|
||||
|
|
Loading…
Reference in New Issue