app/services/client_management/api_credentials/rotate.rb
# Mark existing keys as to be expiring soon
#
# * Author: Puneet
# * Date: 21/01/2019
# * Reviewed By: Sunil
#
# @return [Result::Base]
#
Mark existing keys as to be expiring soon
Author: Puneet
Date: 21/01/2019
Reviewed By: Sunil
Mark existing keys as to be expiring soon Author : Puneet Date : 21 / 01 / 2019 Reviewed By : Sunil
def handle_existing_keys
        existing_rows = ApiCredential.non_expired_for_client(@client_id).select('id, api_key')
        if existing_rows.length == 0
          return success
        elsif existing_rows.length > 1
          return error_with_data(
              's_cm_ac_r_5',
              'client_already_initiated_rotate',
              GlobalConstant::ErrorAction.default
          )
        end
        existing_row = existing_rows.first
        ApiCredential.where(id: existing_row.id).where('expiry_timestamp IS NULL').update_all(
            expiry_timestamp: current_timestamp + @buffer_time * 60,
            updated_at: current_time
        )
        KitSaasSharedCacheManagement::ApiCredentials.new([@client_id]).clear([existing_row.api_key])
        success
      end
def handle_existing_keys existing_rows = ApiCredential . non_expired_for_client ( @client_id ) . select ( 'id, api_key' ) if existing_rows . length == 0 return success elsif existing_rows . length > 1 return error_with_data ( 's_cm_ac_r_5' , 'client_already_initiated_rotate' , GlobalConstant :: ErrorAction . default ) end existing_row = existing_rows . first ApiCredential . where ( id : existing_row . id ) . where ( 'expiry_timestamp IS NULL' ) . update_all ( expiry_timestamp : current_timestamp + @buffer_time * 60 , updated_at : current_time ) KitSaasSharedCacheManagement :: ApiCredentials . new ( [ @client_id ] ) . clear ( [ existing_row . api_key ] ) success end
Mark existing keys as to be expiring soon
 Author: Puneet
 Date: 21/01/2019
 Reviewed By: Sunil
Mark existing keys as to be expiring soon Author : Puneet Date : 21 / 01 / 2019 Reviewed By : Sunil
None
Result::Base