From b448137392eb1cf03fdda258f879274badd9b8e5 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Fri, 6 Sep 2024 10:19:57 +0200 Subject: [PATCH] (bug) unable to reset OpenApi token --- CHANGELOG.md | 2 ++ app/models/open_api/client.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0eadd3e7..b064d1c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next release +- Fix a bug: unable to reset OpenApi token + ## v6.3.32 2024 July 22 - Fix a bug: manager cannot pay a subscription(payment schedule) with a wallet diff --git a/app/models/open_api/client.rb b/app/models/open_api/client.rb index 9d537d379..80e1eabf0 100644 --- a/app/models/open_api/client.rb +++ b/app/models/open_api/client.rb @@ -3,16 +3,16 @@ # OpenAPI::Client keeps track of the authorized accesses to the 3-rd party API (aka. OpenAPI) class OpenAPI::Client < ApplicationRecord validates :name, presence: true - validates_uniqueness_of :token + validates :token, uniqueness: true before_create :set_initial_token def increment_calls_count - update_column(:calls_count, calls_count+1) + update_column(:calls_count, calls_count + 1) end def regenerate_token - update_attributes(token: generate_unique_secure_token) + update(token: generate_unique_secure_token) end private