# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1696875990 -7200
# Node ID 56c1d2498d66d512bf834ff074afe061cb2f81ce
# Parent  14bbfb2cc8ddf81c5b8e4b6a2bdfc6d47dbba81d
mod_tokenauth: Delete grants in the wrong formats on retrieval

diff -r 14bbfb2cc8dd -r 56c1d2498d66 plugins/mod_tokenauth.lua
--- a/plugins/mod_tokenauth.lua	Sun Oct 15 16:43:14 2023 +0200
+++ b/plugins/mod_tokenauth.lua	Mon Oct 09 20:26:30 2023 +0200
@@ -159,6 +159,11 @@
 		return nil, "expired";
 	end
 
+	if not grant.tokens then
+		module:log("debug", "Token grant without tokens, cleaning up");
+		token_store:set_key(username, grant.id, nil);
+		return nil, "invalid";
+	end
 	return grant;
 end