Methods

Class/Module Index [+]

Quicksearch

RHC::Commands::Logout

Public Instance Methods

run() click to toggle source
# File lib/rhc/commands/logout.rb, line 19
def run
  if options.all
    rest_client.user # force authentication
    say "Deleting all authorizations associated with your account ... "
    begin
      rest_client.delete_authorizations
      success "done"
    rescue RHC::Rest::AuthorizationsNotSupported
      info "not supported"
    end
  elsif token_for_user
    options.noprompt = true
    say "Ending session on server ... "
    begin
      rest_client.delete_authorization(token_for_user)
      success "deleted"
    rescue RHC::Rest::AuthorizationsNotSupported
      info "not supported"
    rescue RHC::Rest::TokenExpiredOrInvalid
      info "already closed"
    rescue => e
      debug_error(e)
      warn e.message
    end
  end

  0
ensure
  token_store.clear
  success "All local sessions removed."
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.