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

Fixes #38124 - Invalidate tokens for specific user/users #636

Merged
merged 1 commit into from
Jan 23, 2025
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
27 changes: 27 additions & 0 deletions lib/hammer_cli_foreman/registration_tokens.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module HammerCLIForeman
class RegistrationTokens < HammerCLIForeman::Command
resource :registration_tokens
command_name 'registration-tokens'
desc _('Manage registration tokens')

class InvalidateMultipleCommand < HammerCLIForeman::DeleteCommand
action :invalidate_jwt_tokens
command_name 'invalidate-multiple'
success_message _('Successfully invalidated registration tokens for %{users}.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failure_message is missing for both commands.

Copy link
Contributor Author

@girijaasoni girijaasoni Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a failure message because it will not fail in any case. We are handling other cases like missing params or no record found or permissions etc. We don't have a failure message for API as well. It can fail in UI but not in API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing params or no record found or permissions etc

Those are error states and API returns related messages, e.g. Missing permissions.

It can fail in UI but not in API.

If I call the API with the wrong user id, it fails.

We don't need a failure message

Yes, we do. It's expected way to show why the command failed, please see other commands.

failure_message _('Could not invalidate registration tokens')

build_options
end

class InvalidateCommand < HammerCLIForeman::DeleteCommand
action :invalidate_jwt
command_name 'invalidate'
success_message _('Successfully invalidated registration tokens for %{user}.')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPENDS ON REF
We need to merge that before we merge this

failure_message _('Could not invalidate registration tokens')

build_options
end

autoload_subcommands
end
end
3 changes: 2 additions & 1 deletion lib/hammer_cli_foreman/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class DeleteCommand < HammerCLIForeman::DeleteCommand
lazy_subcommand('table-preference', _("Managing table preferences"),
'HammerCLIForeman::TablePreference', 'hammer_cli_foreman/table_preference'
)
lazy_subcommand('registration-tokens', _("Managing registration tokens"),
'HammerCLIForeman::RegistrationTokens', 'hammer_cli_foreman/registration_tokens')
autoload_subcommands
end

end
Loading