handler_auth.lua 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. local has_xban2_mod = minetest.get_modpath("xban2")
  2. -- auth request from webmail
  3. function mail.handlers.auth(auth)
  4. local handler = minetest.get_auth_handler()
  5. minetest.log("action", "[webmail] auth: " .. auth.name)
  6. local success = false
  7. local banned = false
  8. local message = ""
  9. if mail.webmail.disallow_banned_players and has_xban2_mod then
  10. -- check xban db
  11. local xbanentry = xban.find_entry(auth.name)
  12. if xbanentry and xbanentry.banned then
  13. banned = true
  14. message = "Banned!"
  15. end
  16. end
  17. if not banned then
  18. -- check tan
  19. local tan = mail.tan[auth.name]
  20. if tan ~= nil then
  21. success = tan == auth.password
  22. end
  23. -- check auth
  24. if not success then
  25. local entry = handler.get_auth(auth.name)
  26. if entry and minetest.check_password_entry(auth.name, entry.password, auth.password) then
  27. success = true
  28. end
  29. end
  30. end
  31. mail.channel.send({
  32. type = "auth",
  33. data = {
  34. name = auth.name,
  35. success = success,
  36. message = message
  37. }
  38. })
  39. end