Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reset api token when switching profile #77

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Changes since the last non-beta release.

_Please add entries here for your pull requests that are not yet released._

### Fixed

- Fixed issue where API token is not reset when switching profile. [PR 77](https://github.com/shakacode/heroku-to-control-plane/pull/77) by [Rafael Gomes](https://github.com/rafaelgomesxyz).

## [1.1.0] - 2023-09-20

### Fixed
Expand Down
1 change: 1 addition & 0 deletions lib/core/controlplane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def initialize(config)

def profile_switch(profile)
ENV["CPLN_PROFILE"] = profile
ControlplaneApiDirect.reset_api_token
end

def profile_exists?(profile)
Expand Down
4 changes: 4 additions & 0 deletions lib/core/controlplane_api_direct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ def api_token
raise "Unknown API token format. " \
"Please re-run 'cpln profile login' or set the correct CPLN_TOKEN env variable."
end

def self.reset_api_token
remove_class_variable(:@@api_token) if defined?(@@api_token)
end
# rubocop:enable Style/ClassVars
end