1
0
mirror of https://github.com/MinetestForFun/irc_modpack.git synced 2024-12-23 01:00:36 +01:00

[irc_commands] Remove retro compat' and make checkToken precise

This commit is contained in:
LeMagnesium 2016-08-21 00:50:43 +02:00
parent 07e6a4dc54
commit c32607320f
No known key found for this signature in database
GPG Key ID: A54DDB5272C51E8B

View File

@ -137,22 +137,12 @@ function checkToken(playerName, token, usernick)
else else
minetest.log("action", usernick.."@IRC attempted to log in as " minetest.log("action", usernick.."@IRC attempted to log in as "
..playerName.." unsuccessfully using a token") ..playerName.." unsuccessfully using a token")
return false, "Incorrect token or player does not exist." if irc_tokens[playerName] then
end return false, "Invalid token for player " .. playerName .. "."
end else
return false, "No token generated by that player."
end
function checkPassword(playerName, password, usernick)
if minetest.auth_table[playerName] and
minetest.auth_table[playerName].password ==
minetest.get_password_hash(playerName, password) then
minetest.log("action", "User "..usernick
.." from IRC logs in as "..playerName)
irc_users[usernick] = playerName
return true, "You are now logged in as "..playerName
else
minetest.log("action", usernick.."@IRC attempted to log in as "
..playerName.." unsuccessfully")
return false, "Incorrect password or player does not exist."
end end
end end
@ -179,22 +169,7 @@ irc:register_bot_command("login", {
return false, "You need to be in the server's channel to login." return false, "You need to be in the server's channel to login."
end end
local u, m = checkToken(playerName, password, user.nick) return checkToken(playerName, password, user.nick)
if not u then
if minetest.auth_table and minetest.auth_table[playerName] and minetest.auth_table[playerName].password:sub(1,3) == "#1#" then -- First SRP mechanism
if not irc_tokens[playerName] then
return false, "No token available for your nickname. " ..
"Please consider generating one with /gen_token"
else
return u, m
end
else
-- The old mechanism
return checkPassword(playerName, password, user.nick)
end
else
return u, m
end
end end
}) })