0
votes

I am following the Miguel Grinberg book on Flask Web Development and while authorising I came across the following code snippet where unconfirmed users are either given access if they are confirmed or are redirected to the same page.

@auth.route('/unconfirmed')
def unconfirmed():
    if current_user.is_anonymous() or current_user.confirmed:
        return redirect(url_for('main.index'))
    return render_template('auth/unconfirmed.html')

I want to clarify the role of

current_user.is_anonymous().

Why is this particular condition also checked? Also, what will happen if this condition is satisfied (when i tested it was transferring to 404.html which I dont understand why?

1

1 Answers

2
votes

The unconfirmed route is supposed to show a page to users who have registered but haven't confirmed their account. Users that have confirmed their account, or users that haven't registered (anonymous, non-logged in users) should not see that page, so they are redirected away.