Skip to content

Commit 2d71d7d

Browse files
committed
Merge pull request #1181 from adamrp/verify_code-issue-1178
BUG: Check that result is not None before indexing
2 parents ab35e4c + ce7c5b5 commit 2d71d7d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

qiita_db/user.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,15 @@ def verify_code(cls, email, code, code_type):
272272
sql = ("SELECT {1} from qiita.{0} where email"
273273
" = %s".format(cls._table, column))
274274
conn_handler = SQLConnectionHandler()
275-
db_code = conn_handler.execute_fetchone(sql, (email,))[0]
275+
db_code = conn_handler.execute_fetchone(sql, (email,))
276+
277+
# If the query didn't return anything, then there's no way the code
278+
# can match
279+
if db_code is None:
280+
return False
281+
282+
db_code = db_code[0]
283+
276284
if db_code == code and code_type == "create":
277285
# verify the user
278286
level = conn_handler.execute_fetchone(

0 commit comments

Comments
 (0)