Add CI workflow test
parent
a3acf31f96
commit
1c82b35b14
|
@ -0,0 +1,11 @@
|
|||
on: [push, pull_request]
|
||||
name: Check & Release
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: lint
|
||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
||||
with:
|
||||
luacheckrc_url: https://raw.githubusercontent.com/shivajiva101/sauth/0.4/.luacheckrc
|
|
@ -0,0 +1,9 @@
|
|||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
read_globals = {
|
||||
"minetest", "dump",
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
"vector", "default",
|
||||
}
|
48
init.lua
48
init.lua
|
@ -50,7 +50,6 @@ local function fetch_cache()
|
|||
local last = it(state)
|
||||
if last then
|
||||
last = last.result - ttl
|
||||
local r = {}
|
||||
q = ([[SELECT * FROM auth WHERE last_login > %s LIMIT %s;
|
||||
]]):format(last, max_cache_records)
|
||||
for row in db:nrows(q) do
|
||||
|
@ -242,22 +241,22 @@ sauth.auth_handler = {
|
|||
-- cache
|
||||
privileges = r.privileges
|
||||
end
|
||||
if core.settings then
|
||||
admin = core.settings:get("name")
|
||||
if minetest.settings then
|
||||
admin = minetest.settings:get("name")
|
||||
else
|
||||
-- use old api
|
||||
admin = core.setting_get("name")
|
||||
admin = minetest.setting_get("name")
|
||||
end
|
||||
-- If singleplayer, grant privileges marked give_to_singleplayer = true
|
||||
if core.is_singleplayer() then
|
||||
for priv, def in pairs(core.registered_privileges) do
|
||||
if minetest.is_singleplayer() then
|
||||
for priv, def in pairs(minetest.registered_privileges) do
|
||||
if def.give_to_singleplayer then
|
||||
privileges[priv] = true
|
||||
end
|
||||
end
|
||||
-- If admin, grant all privileges
|
||||
elseif name == admin then
|
||||
for priv, def in pairs(core.registered_privileges) do
|
||||
for priv, def in pairs(minetest.registered_privileges) do
|
||||
privileges[priv] = true
|
||||
end
|
||||
end
|
||||
|
@ -277,12 +276,13 @@ sauth.auth_handler = {
|
|||
create_auth = function(name, password)
|
||||
assert(type(name) == 'string')
|
||||
assert(type(password) == 'string')
|
||||
local ts, privs = os.time()
|
||||
if core.settings then
|
||||
privs = core.settings:get("default_privs")
|
||||
local ts = os.time()
|
||||
local privs
|
||||
if minetest.settings then
|
||||
privs = minetest.settings:get("default_privs")
|
||||
else
|
||||
-- use old api
|
||||
privs = core.setting_get("default_privs")
|
||||
privs = minetest.setting_get("default_privs")
|
||||
end
|
||||
-- Params: name, password, privs, last_login
|
||||
add_record(name,password,privs,ts)
|
||||
|
@ -315,22 +315,22 @@ sauth.auth_handler = {
|
|||
assert(type(privs) == 'table')
|
||||
if not sauth.auth_handler.get_auth(name) then
|
||||
-- create the record
|
||||
if core.settings then
|
||||
if minetest.settings then
|
||||
sauth.auth_handler.create_auth(name,
|
||||
core.get_password_hash(name,
|
||||
core.settings:get("default_password")))
|
||||
minetest.get_password_hash(name,
|
||||
minetest.settings:get("default_password")))
|
||||
else
|
||||
sauth.auth_handler.create_auth(name,
|
||||
core.get_password_hash(name,
|
||||
core.setting_get("default_password")))
|
||||
minetest.get_password_hash(name,
|
||||
minetest.setting_get("default_password")))
|
||||
end
|
||||
end
|
||||
local admin
|
||||
if core.settings then
|
||||
admin = core.settings:get("name")
|
||||
if minetest.settings then
|
||||
admin = minetest.settings:get("name")
|
||||
else
|
||||
-- use old api method
|
||||
admin = core.setting_get("name")
|
||||
admin = minetest.setting_get("name")
|
||||
end
|
||||
if name == admin then privs.privs = true end
|
||||
update_privileges(name, minetest.privs_to_string(privs))
|
||||
|
@ -447,7 +447,7 @@ if get_setting("import") == nil then
|
|||
|
||||
local function db_import()
|
||||
-- local instance creates player, update or duplication occurs!
|
||||
local player_name = core.get_connected_players() or ""
|
||||
local player_name = minetest.get_connected_players() or ""
|
||||
if type(player_name) == 'table' and #player_name > 0 then
|
||||
player_name = player_name[1].name
|
||||
end
|
||||
|
@ -479,10 +479,10 @@ if get_setting("import") == nil then
|
|||
-- rename auth.txt otherwise it will still load!
|
||||
ie.os.rename(WP.."/auth.txt", WP.."/auth.txt.bak")
|
||||
-- removed from later versions of minetest
|
||||
if core.auth_table then
|
||||
core.auth_table = {} -- unload redundant data
|
||||
end
|
||||
core.notify_authentication_modified()
|
||||
--if minetest.auth_table then
|
||||
--minetest.auth_table = {} -- unload redundant data
|
||||
--end
|
||||
minetest.notify_authentication_modified()
|
||||
end
|
||||
minetest.after(5, task)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue