Class: Yunpian::Captcha::AuthService

Inherits:
Object
  • Object
show all
Defined in:
lib/yunpian/captcha/auth_service.rb

Constant Summary collapse

PARAMS =
%w[captchaId token authenticate secretId version user timestamp nonce signature]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, authenticate, config = Yunpian::Captcha.config) ⇒ AuthService

Returns a new instance of AuthService.



9
10
11
# File 'lib/yunpian/captcha/auth_service.rb', line 9

def initialize(token, authenticate, config = Yunpian::Captcha.config)
  @config, @token, @authenticate = config, token, authenticate
end

Instance Attribute Details

#authenticateObject (readonly)

Returns the value of attribute authenticate.



8
9
10
# File 'lib/yunpian/captcha/auth_service.rb', line 8

def authenticate
  @authenticate
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/yunpian/captcha/auth_service.rb', line 8

def config
  @config
end

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/yunpian/captcha/auth_service.rb', line 8

def token
  @token
end

Instance Method Details

#callObject



13
14
15
16
17
# File 'lib/yunpian/captcha/auth_service.rb', line 13

def call
  log :debug, 'verifying'
  signed_params = sign(build_params)
  valid?(signed_params)
end