mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Fix /setpassword and /clearpassword
This commit is contained in:
parent
d15d6c4e6b
commit
57550b2b3d
@ -193,12 +193,27 @@ minetest.register_chatcommand("setpassword", {
|
|||||||
description = "set given password",
|
description = "set given password",
|
||||||
privs = {password=true},
|
privs = {password=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "" then
|
local toname, raw_password = string.match(param, "^([^ ]+) +(.+)$")
|
||||||
minetest.chat_send_player(name, "Password field required")
|
if not toname then
|
||||||
|
toname = string.match(param, "^([^ ]+) *$")
|
||||||
|
raw_password = nil
|
||||||
|
end
|
||||||
|
if not toname then
|
||||||
|
minetest.chat_send_player(name, "Name field required")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
minetest.set_player_password(name, param)
|
local actstr = "?"
|
||||||
minetest.chat_send_player(name, "Password set")
|
if not raw_password then
|
||||||
|
minetest.set_player_password(toname, "")
|
||||||
|
actstr = "cleared"
|
||||||
|
else
|
||||||
|
minetest.set_player_password(toname, minetest.get_password_hash(toname, raw_password))
|
||||||
|
actstr = "set"
|
||||||
|
end
|
||||||
|
minetest.chat_send_player(name, "Password of player \""..toname.."\" "..actstr)
|
||||||
|
if toname ~= name then
|
||||||
|
minetest.chat_send_player(toname, "Your password was "..actstr.." by "..name)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
minetest.register_chatcommand("clearpassword", {
|
minetest.register_chatcommand("clearpassword", {
|
||||||
@ -206,8 +221,13 @@ minetest.register_chatcommand("clearpassword", {
|
|||||||
description = "set empty password",
|
description = "set empty password",
|
||||||
privs = {password=true},
|
privs = {password=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
minetest.set_player_password(name, '')
|
toname = param
|
||||||
minetest.chat_send_player(name, "Password cleared")
|
if not toname then
|
||||||
|
minetest.chat_send_player(toname, "Name field required")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.set_player_password(toname, '')
|
||||||
|
minetest.chat_send_player(name, "Password of player \""..toname.."\" cleared")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user