Class: AdsCommon::Auth::ClientLoginHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/ads_common/auth/client_login_handler.rb

Overview

Credentials class to handle ClientLogin authentication.

Constant Summary collapse

ACCOUNT_TYPE =
'GOOGLE'
AUTH_PATH =
'/accounts/ClientLogin'
AUTH_PREFIX =
'GoogleLogin auth='
CAPTCHA_PATH =
'/accounts/'

Instance Method Summary collapse

Methods inherited from BaseHandler

#get_token

Constructor Details

#initialize(config, auth_server, service_name) ⇒ ClientLoginHandler

Initializes the ClientLoginHandler with all the necessary details.



40
41
42
43
44
# File 'lib/ads_common/auth/client_login_handler.rb', line 40

def initialize(config, auth_server, service_name)
  super(config)
  @server = auth_server
  @service_name = service_name
end

Instance Method Details

#auth_string(credentials) ⇒ Object

Returns authorization string.



66
67
68
# File 'lib/ads_common/auth/client_login_handler.rb', line 66

def auth_string(credentials)
  return [AUTH_PREFIX, get_token(credentials)].join
end

#handle_error(error) ⇒ Object

Handle specific ClientLogin errors.



58
59
60
61
62
63
# File 'lib/ads_common/auth/client_login_handler.rb', line 58

def handle_error(error)
  # TODO: Add support for automatically regenerating auth tokens when they
  # expire.
  get_logger().error(error)
  raise error
end

#property_changed(prop, value) ⇒ Object

Invalidates the stored token if the email, password or provided auth token have changed.



48
49
50
51
52
53
54
55
# File 'lib/ads_common/auth/client_login_handler.rb', line 48

def property_changed(prop, value)
  if [:email, :password].include?(prop)
    @token = nil
  end
  if :auth_token.eql?(prop)
    @token = create_token_from_string(value)
  end
end