Changeset

10290:b2ce3300f26a

mod_register_ibr: Distinguish between failure to create account or save extra data
author Kim Alvefur <zash@zash.se>
date Sun, 29 Sep 2019 17:34:47 +0200
parents 10289:8c59b20f71dc
children 10291:7b48b620164c
files plugins/mod_register_ibr.lua
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_register_ibr.lua	Sun Sep 29 17:30:54 2019 +0200
+++ b/plugins/mod_register_ibr.lua	Sun Sep 29 17:34:47 2019 +0200
@@ -179,14 +179,13 @@
 		return true;
 	end
 
-	-- TODO unable to write file, file may be locked, etc, what's the correct error?
-	local error_reply = st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk.");
-	if usermanager_create_user(username, password, host) then
+	local created, err = usermanager_create_user(username, password, host);
+	if created then
 		data.registered = os.time();
 		if not account_details:set(username, data) then
 			log("debug", "Could not store extra details");
 			usermanager_delete_user(username, host);
-			session.send(error_reply);
+			session.send(st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."));
 			return true;
 		end
 		session.send(st.reply(stanza)); -- user created!
@@ -195,8 +194,8 @@
 			username = username, host = host, source = "mod_register",
 			session = session });
 	else
-		log("debug", "Could not create user");
-		session.send(error_reply);
+		log("debug", "Could not create user", err);
+		session.send(st.error_reply(stanza, "cancel", "feature-not-implemented", err));
 	end
 	return true;
 end);