Changeset

2934:060bb8217fea

usermanager: Added function set_password.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 24 Mar 2010 00:03:31 +0500
parents 2931:de4daf300f19
children 2935:4e4d0d899d9d
files core/usermanager.lua
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/usermanager.lua	Tue Mar 23 20:55:28 2010 +0500
+++ b/core/usermanager.lua	Wed Mar 24 00:03:31 2010 +0500
@@ -55,6 +55,15 @@
 	if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end
 	return (datamanager.load(username, host, "accounts") or {}).password
 end
+function set_password(username, host, password)
+	if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end
+	local account = datamanager.load(username, host, "accounts");
+	if account then
+		account.password = password;
+		return datamanager.store(username, host, "accounts", account);
+	end
+	return nil, "Account not available.";
+end
 
 function user_exists(username, host)
 	if is_cyrus(host) then return true; end