Module: AccessTokensActions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/access_tokens_actions.rb
Instance Method Summary collapse
-
#create ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables.
-
#index ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables.
-
#revoke ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables.
Instance Method Details
#create ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/concerns/access_tokens_actions.rb', line 27 def create token_response = ResourceAccessTokens::CreateService.new(current_user, resource, create_params).execute if token_response.success? @resource_access_token = token_response.payload[:access_token] render json: { new_token: @resource_access_token.token, active_access_tokens: active_access_tokens }, status: :ok else render json: { errors: token_response.errors }, status: :unprocessable_entity end end |
#index ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/concerns/access_tokens_actions.rb', line 13 def index @resource_access_token = PersonalAccessToken.new set_index_vars respond_to do |format| format.html format.json do render json: @active_access_tokens end end end |
#revoke ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/concerns/access_tokens_actions.rb', line 41 def revoke @resource_access_token = finder.find(params[:id]) revoked_response = ResourceAccessTokens::RevokeService.new(current_user, resource, @resource_access_token).execute if revoked_response.success? flash[:notice] = format(_("Revoked access token %{access_token_name}!"), access_token_name: @resource_access_token.name) else flash[:alert] = format(_("Could not revoke access token %{access_token_name}."), access_token_name: @resource_access_token.name) end redirect_to resource_access_tokens_path end |