diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2020-10-10 23:35:44 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2020-10-10 23:35:44 +0200 |
commit | 68e8a0562d68e609e31e0a2b4eb0316c0bdeb8eb (patch) | |
tree | bf86cb8ad567eb6f1392c480c03db66ceb39b5e3 /auth_export/webmail.lua | |
parent | 51fd69402daad7eb6761e5cc22170e9a762e99c1 (diff) | |
parent | ad25fb61f76b88e27caa9d9bd9759c990c400a7f (diff) | |
download | forks-modpack-68e8a0562d68e609e31e0a2b4eb0316c0bdeb8eb.tar.gz forks-modpack-68e8a0562d68e609e31e0a2b4eb0316c0bdeb8eb.tar.bz2 forks-modpack-68e8a0562d68e609e31e0a2b4eb0316c0bdeb8eb.zip |
Merge commit 'ad25fb61f76b88e27caa9d9bd9759c990c400a7f' as 'auth_export'
Diffstat (limited to 'auth_export/webmail.lua')
-rw-r--r-- | auth_export/webmail.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/auth_export/webmail.lua b/auth_export/webmail.lua new file mode 100644 index 0000000..5131adf --- /dev/null +++ b/auth_export/webmail.lua @@ -0,0 +1,53 @@ +-- false per default +local has_xban2_mod = minetest.get_modpath("xban2") + +local MP = minetest.get_modpath(minetest.get_current_modname()) +local Channel = dofile(MP .. "/channel.lua") +local channel +-- auth request from webmail +local function auth_handler(auth) + local handler = minetest.get_auth_handler() + minetest.log("action", "[webmail] auth: " .. auth.name) + + local success = false + local banned = false + local message = "" + + if mail.webmail.disallow_banned_players and has_xban2_mod then + -- check xban db + local xbanentry = xban.find_entry(auth.name) + if xbanentry and xbanentry.banned then + banned = true + message = "Banned!" + end + end + + if not banned then + local entry = handler.get_auth(auth.name) + if entry and minetest.check_password_entry(auth.name, entry.password, auth.password) then + success = true + end + end + + channel.send({ + type = "auth", + data = { + name = auth.name, + success = success, + message = message + } + }) +end + + +function mail.webmail_init(http, url, key) + channel = Channel(http, url .. "/api/minetest/channel", { + extra_headers = { "webmailkey: " .. key } + }) + + channel.receive(function(data) + if data.type == "auth" then + auth_handler(data.data) + end + end) +end |