mod_tokenauth: return error if storage of new token fails
authorMatthew Wild <mwild1@gmail.com>
Sun, 26 Mar 2023 15:53:27 +0100
changeset 13000 e8716515405e
parent 12999 e385f3a06673
child 13001 0a56b84ec4ad
mod_tokenauth: return error if storage of new token fails
plugins/mod_tokenauth.lua
--- a/plugins/mod_tokenauth.lua	Sun Mar 26 14:06:04 2023 +0100
+++ b/plugins/mod_tokenauth.lua	Sun Mar 26 15:53:27 2023 +0100
@@ -54,10 +54,13 @@
 
 	local token_secret = random.bytes(18);
 	local token = "secret-token:"..base64.encode("2;"..token_id..";"..token_secret..";"..jid.join(token_username, token_host));
-	token_store:set(token_username, token_id, {
+	local ok, err = token_store:set(token_username, token_id, {
 		secret_sha256 = hashes.sha256(token_secret, true);
 		token_info = token_info
 	});
+	if not ok then
+		return nil, err;
+	end
 
 	return token, token_info;
 end