0
0
Flaskframework~20 mins

Email verification pattern in Flask - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Email Verification Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What happens after a user clicks the email verification link?

In a Flask app using an email verification pattern, what is the typical behavior after the user clicks the verification link sent to their email?

AThe app marks the user as verified and redirects them to a confirmation page.
BThe app deletes the user account immediately.
CThe app sends another verification email automatically.
DThe app logs the user out without any message.
Attempts:
2 left
💡 Hint

Think about what the verification link is supposed to confirm.

📝 Syntax
intermediate
2:00remaining
Which Flask route correctly handles email verification tokens?

Given a Flask app, which route code correctly extracts and verifies an email token from the URL?

Flask
from flask import Flask, request, redirect
app = Flask(__name__)

@app.route('/verify/<token>')
def verify_email(token):
    # Verify token logic here
    pass
A
def verify_email(token):
    # token is a query param
    token = request.args['token']
    # verify token
    return redirect('/confirmed')
B
def verify_email():
    token = request.args.get('token')
    # verify token
    return redirect('/confirmed')
C
def verify_email(token):
    if not token:
        return 'Invalid token', 400
    # verify token
    return redirect('/confirmed')
D
def verify_email(token):
    token = request.form['token']
    # verify token
    return redirect('/confirmed')
Attempts:
2 left
💡 Hint

Check how the token is passed in the URL path and accessed in the function.

state_output
advanced
1:30remaining
What is the user status after verification token expires?

In a Flask email verification system, if a user clicks an expired verification token link, what should be the typical user status in the database?

AThe user remains unverified and must request a new verification email.
BThe user is automatically deleted from the database.
CThe user is marked as verified despite the expired token.
DThe user is locked out permanently.
Attempts:
2 left
💡 Hint

Think about what happens when verification fails due to expiration.

🔧 Debug
advanced
2:00remaining
Why does this Flask email verification code raise an error?

Consider this Flask route snippet for email verification. Why does it raise a TypeError?

Flask
from flask import Flask, redirect
app = Flask(__name__)

@app.route('/verify/<token>')
def verify_email():
    if not token:
        return 'Invalid token', 400
    # verify token
    return redirect('/confirmed')
AThe redirect function is used incorrectly without parentheses.
BThe function is missing the 'token' parameter required by the route.
CThe route decorator syntax is invalid.
DThe 'if not token' check causes a syntax error.
Attempts:
2 left
💡 Hint

Check the function parameters matching the route variables.

🧠 Conceptual
expert
2:00remaining
What is the main security risk if email verification tokens are not time-limited?

In an email verification pattern using Flask, what is the main security risk if tokens never expire?

AEmails would be sent repeatedly causing spam.
BUsers would be unable to verify their emails at all.
CThe server would crash due to token overload.
DAttackers could reuse old tokens to verify unauthorized accounts.
Attempts:
2 left
💡 Hint

Think about what happens if tokens stay valid forever.