diff --git a/irc_commands/init.lua b/irc_commands/init.lua index 4a31ca3..3d6ab50 100755 --- a/irc_commands/init.lua +++ b/irc_commands/init.lua @@ -137,22 +137,12 @@ function checkToken(playerName, token, usernick) else minetest.log("action", usernick.."@IRC attempted to log in as " ..playerName.." unsuccessfully using a token") - return false, "Incorrect token or player does not exist." - end -end + if irc_tokens[playerName] then + return false, "Invalid token for player " .. playerName .. "." + 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 @@ -179,22 +169,7 @@ irc:register_bot_command("login", { return false, "You need to be in the server's channel to login." end - local u, m = 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 + return checkToken(playerName, password, user.nick) end })