From ce7c5b513849f5eba6e7a60d9ee00cf3bb023ad2 Mon Sep 17 00:00:00 2001 From: Adam Robbins-Pianka Date: Thu, 14 May 2015 15:56:22 -0600 Subject: [PATCH] BUG: Check that result is not None before indexing Fix #1178 --- qiita_db/user.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qiita_db/user.py b/qiita_db/user.py index 58a570469..bd1e74a58 100644 --- a/qiita_db/user.py +++ b/qiita_db/user.py @@ -272,7 +272,15 @@ def verify_code(cls, email, code, code_type): sql = ("SELECT {1} from qiita.{0} where email" " = %s".format(cls._table, column)) conn_handler = SQLConnectionHandler() - db_code = conn_handler.execute_fetchone(sql, (email,))[0] + db_code = conn_handler.execute_fetchone(sql, (email,)) + + # If the query didn't return anything, then there's no way the code + # can match + if db_code is None: + return False + + db_code = db_code[0] + if db_code == code and code_type == "create": # verify the user level = conn_handler.execute_fetchone(