• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

blockexchange / blockexchange / 13110168475

03 Feb 2025 09:18AM UTC coverage: 48.213% (+0.6%) from 47.564%
13110168475

push

github

BuckarooBanzay
http/json overhaul

51 of 102 new or added lines in 14 files covered. (50.0%)

1 existing line in 1 file now uncovered.

985 of 2043 relevant lines covered (48.21%)

1734.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/commands/user.lua
1

2
minetest.register_chatcommand("bx_login", {
2✔
3
        params = "<username> <access_token>",
4
        description = "Login with an existing user and access_token or check the current login",
5
        func = function(name, param)
6
                if not minetest.check_player_privs(name, { blockexchange = true }) and
×
7
                        not minetest.check_player_privs(name, { blockexchange_protected_upload = true }) then
×
8
                                return false, "Required privs: 'blockexchange' or 'blockexchange_protected_upload'"
×
9
                end
10

11
                local _, _, username, access_token = string.find(param, "^([^%s]+)%s+([^%s]+)%s*$")
×
12
                if not username or not access_token then
×
13
                        local token = blockexchange.get_token(name)
×
14
                        if not token then
×
15
                                -- not logged in
16
                                return false, "Not logged in, usage: /bx_login <username> <access_token>"
×
17
                        end
18

19
                        -- logged in, show status
20
                        local payload = blockexchange.parse_token(token)
×
21
                        if not payload or not payload.user_uid then
×
22
                                -- invalid or old token
23
                                -- TODO: check validity
24
                                return false, "Not logged in, token invalid or expired"
×
25
                        end
26

27
                        return true, "Logged in as '" .. payload.username .. "' with user_uid: " .. payload.user_uid
×
28
                end
29

30
                blockexchange.api.get_token(username, access_token):next(function(token)
×
31
                        blockexchange.set_token(name, token)
×
32
                        local payload = blockexchange.parse_token(token)
×
33
                        minetest.chat_send_player(name, "Logged in as '" .. payload.username .. "' with user_uid: " .. payload.user_uid)
×
NEW
34
                end):catch(function(err)
×
NEW
35
                        minetest.log("error", "[blockexchange] get_token failed: " .. err or "?")
×
NEW
36
                        minetest.chat_send_player(name, "Login failed: " .. err or "?")
×
37
                end)
38
  end
39
})
40

41
minetest.register_chatcommand("bx_logout", {
2✔
42
        description = "Logs the current user out",
43
        func = function(name)
44
                blockexchange.set_token(name)
×
45
                minetest.chat_send_player(name, "Logged out successfully")
×
46
  end
47
})
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc