Comparison

plugins/mod_admin_shell.lua @ 13598:2cd43975a15c

mod_admin_shell: user:password(): Support prompting for password if none given
author Matthew Wild <mwild1@gmail.com>
date Tue, 07 Jan 2025 19:25:12 +0000 (7 months ago)
parent 13597:62aca6adcfd3
child 13603:6e5124f72e9a
comparison
equal deleted inserted replaced
13597:62aca6adcfd3 13598:2cd43975a15c
1788 if not prosody.hosts[host] then 1788 if not prosody.hosts[host] then
1789 return nil, "No such host: "..host; 1789 return nil, "No such host: "..host;
1790 elseif not um.user_exists(username, host) then 1790 elseif not um.user_exists(username, host) then
1791 return nil, "No such user"; 1791 return nil, "No such user";
1792 end 1792 end
1793 local ok, err = um.set_password(username, password, host, nil); 1793
1794 if ok then 1794 return promise.resolve(password or self.session.request_input("password")):next(function (password_)
1795 return true, "User password changed"; 1795 local ok, err = um.set_password(username, password_, host, nil);
1796 else 1796 if ok then
1797 return nil, "Could not change password for user: "..err; 1797 return "User password changed";
1798 end 1798 else
1799 return promise.reject("Could not change password for user: "..err);
1800 end
1801 end);
1799 end 1802 end
1800 1803
1801 describe_command [[user:roles(jid, host) - Show current roles for an user]] 1804 describe_command [[user:roles(jid, host) - Show current roles for an user]]
1802 function def_env.user:role(jid, host) 1805 function def_env.user:role(jid, host)
1803 local print = self.session.print; 1806 local print = self.session.print;