2023-08-05 12:44:09 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class ApiSettingsController < ApplicationController
|
2023-09-17 00:45:57 +03:00
|
|
|
def index
|
|
|
|
|
authorize!(:read, current_user.access_token)
|
|
|
|
|
end
|
2024-01-06 12:34:20 +02:00
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
authorize!(:manage, current_user.access_token)
|
|
|
|
|
|
|
|
|
|
current_user.access_token.token = SecureRandom.base58(AccessToken::TOKEN_LENGTH)
|
|
|
|
|
|
|
|
|
|
current_user.access_token.save!
|
|
|
|
|
|
2024-09-18 19:47:47 +03:00
|
|
|
redirect_back(fallback_location: settings_api_index_path, notice: I18n.t('api_token_has_been_updated'))
|
2024-01-06 12:34:20 +02:00
|
|
|
end
|
2023-08-05 12:44:09 +03:00
|
|
|
end
|