blob: 5131adf7b0e75e030d8c7b161646df14c134a26a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
|