Predict the output
A token issued at 1000 is checked after the user's 'valid after' moved to 1500. What's printed?
valid_after = {"user-7": 1500}
def accept(sub: str, issued_at: int) -> bool:
return issued_at >= valid_after.get(sub, 0)
print(accept("user-7", 1000), accept("user-7", 1600))Hint 1 of 1
Compare iat with the cut-off.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A False True
Correct. Tokens issued before the cut-off fail; new logins work.
A per-user 'valid after' time revokes every token issued before it in one write. The check compares each token's issued-at time with that cut-off, so 1000 fails and 1600 passes.
Why not the others?
- B
True True. The old token predates the cut-off. - C
False False. Tokens issued after 1500 are fine. - D
True False. Reversed.