add rotate api token button

This commit is contained in:
Pete Matsyburka
2024-01-06 12:34:20 +02:00
parent 7dc342a6f9
commit ab9cc52bcc
3 changed files with 12 additions and 1 deletions
@@ -4,4 +4,14 @@ class ApiSettingsController < ApplicationController
def index
authorize!(:read, current_user.access_token)
end
def create
authorize!(:manage, current_user.access_token)
current_user.access_token.token = SecureRandom.base58(AccessToken::TOKEN_LENGTH)
current_user.access_token.save!
redirect_back(fallback_location: settings_api_index_path, notice: 'API token as been updated.')
end
end