lib/mrkt/concerns/authentication.rb in mrkt-0.6.2 vs lib/mrkt/concerns/authentication.rb in mrkt-0.7.0

- old
+ new

@@ -1,8 +1,19 @@ module Mrkt module Authentication def authenticate! - authenticate unless authenticated? + return if authenticated? + + authenticate + + if !authenticated? && @retry_authentication + @retry_authentication_count.times do + sleep(@retry_authentication_wait_seconds) if @retry_authentication_wait_seconds > 0 + authenticate + break if authenticated? + end + end + fail Mrkt::Errors::AuthorizationError, 'Client not authenticated' unless authenticated? end def authenticated? @token && valid_token?