[add] added maximum client and demo client protection

- default demo clients can no longer be modified/deleted when in demo mode
 - increased default demo reset to 60 minutes
This commit is contained in:
2021-02-25 12:52:23 -05:00
parent 472ae4c90f
commit 5868377210
7 changed files with 60 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
class Client < ApplicationRecord
def self.new_client(params)
return nil if count >= RynDNS::Application::MAX_CLIENTS
perm_string = params[:permission] || 'w' # create write client by default
perm_rwx = Client.parse_perm_string(perm_string)
@@ -28,7 +30,7 @@ class Client < ApplicationRecord
def gen_api_key
api_key = SecureRandom.hex(32)
self.api_key = api_key
"#{RynDNS::Application::API_KEY_PREFIX}.#{self.name_id}.#{api_key}"
"#{RynDNS::Application::API_KEY_PREFIX}.#{name_id}.#{api_key}"
end
def api_key