1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-05 20:46:14 +01:00
fab-manager/app/controllers/api/version_controller.rb
Sylvain de9c224a92 improved version check
- use referer from client when available
- save uuid returned by hub
- send uuid to hub on version check
- check the version on each startup to prevent wrong sync
- also: do not save a setting on API update if it has not changed
2020-04-07 17:53:19 +02:00

25 lines
624 B
Ruby

# frozen_string_literal: true
require 'version'
# API Controller to get the Fab-manager version
class API::VersionController < API::ApiController
before_action :authenticate_user!
def show
authorize :version
# save the origin
origin = Setting.find_or_create_by(name: 'origin')
if origin.value != params[:origin]
origin.value = params[:origin]
origin.save!
end
# get the last version
update_status = Setting.find_by(name: 'hub_last_version')&.value || '{}'
json = JSON.parse(update_status)
json['current'] = Version.current
render json: json, status: :ok
end
end