Permalink
Browse files

Fix the use of deprecated api

Remove the token expiration check. It was not being invoked, the
retry logic is already effective and is better anyway

Change-Id: Ia24936d19f5ae805c5c45ecaf7ebe9b20c212576
  • Loading branch information...
1 parent 2e25cb0 commit 5a6bd42cf5ceb9c9bdd7ad0ccc35ac23a5f6c16d @joeldsa joeldsa committed Oct 31, 2012
@@ -12,8 +12,10 @@ def create
begin
user_account = UaaToken.user_account_instance
retry_on_error = (retry_on_error == true ? false : true)
- user = user_account.create(body_params[:email], body_params[:password], body_params[:email])
- CloudController.logger.info("User with email #{body_params[:email]} and id #{user[:id]} created in the UAA") unless user == nil
+ email = body_params[:email]
+ password = body_params[:password]
+ user = user_account.add({userName: email, password: password, name: {givenName: email, familyName: email}})
+ CloudController.logger.info("User with email #{email} and id #{user[:id]} created in the UAA") unless user == nil
rescue CF::UAA::InvalidToken => ite
# Try again. The UAA may have restarted and may have lost it's token cache
CloudController.logger.debug("Appears to be an invalid token, retrying - message #{ite.message} trace #{ite.backtrace[0..10]}")
@@ -63,18 +63,13 @@ def decode_token(auth_token)
token_information[:email] if token_information
end
- def expired?(access_token)
- expiry = CF::UAA::TokenCoder.decode(access_token.split()[1], AppConfig[:uaa][:token_secret])[:expires_at]
- expiry.is_a?(Integer) && expiry <= Time.now.to_i
- end
-
def expire_access_token
@access_token = nil
@user_account = nil
end
def access_token
- if @access_token.nil? || expired?(@access_token)
+ if @access_token.nil?
#Get a new one
@token_issuer.async = true
@token_issuer.logger = CloudController.logger

0 comments on commit 5a6bd42

Please sign in to comment.