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!
|
|
|
|
|
|
|
|
|
|
redirect_back(fallback_location: settings_api_index_path, notice: 'API token as been updated.')
|
|
|
|
|
end
|
2023-08-05 12:44:09 +03:00
|
|
|
end
|