# HG changeset patch # User Matthew Wild # Date 1679842407 -3600 # Node ID e8716515405eba4b9d80afdfb2adbef04f6ed544 # Parent e385f3a0667391fd70b39c27ecb3f8fdca97ef34 mod_tokenauth: return error if storage of new token fails diff -r e385f3a06673 -r e8716515405e 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