akkounts/app/controllers/services/rs_auths_controller.rb
Râu Cao aa399b862a
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Allow to launch RS apps from dashboard
2023-11-19 19:10:13 +01:00

42 lines
1.1 KiB
Ruby

class Services::RsAuthsController < Services::BaseController
before_action :authenticate_user!
before_action :require_feature_enabled
before_action :require_service_available
# before_action :require_service_enabled
def destroy
if auth = current_user.remote_storage_authorizations.find(params[:id])
auth.destroy!
else
http_status :not_found
end
respond_to do |format|
format.html do redirect_to services_storage_url, flash: {
success: 'App authorization revoked'
}
end
format.json { head :no_content }
end
end
def launch_app
auth = current_user.remote_storage_authorizations.find(params[:id])
launch_url = "#{auth.url}#remotestorage=#{current_user.address}&access_token=#{auth.token}"
redirect_to launch_url, allow_other_host: true
end
private
def require_feature_enabled
unless Flipper.enabled?(:remotestorage, current_user)
http_status :forbidden
end
end
def require_service_available
http_status :not_found unless Setting.remotestorage_enabled?
end
end