Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed to log in even before confirming email #17

Closed
sandlerben opened this issue Oct 24, 2015 · 8 comments
Closed

Allowed to log in even before confirming email #17

sandlerben opened this issue Oct 24, 2015 · 8 comments

Comments

@sandlerben
Copy link
Contributor

Steps to reproduce:

  1. Make an account
  2. Don't confirm email
  3. Log in with account

Expected
4. See message that asks to reconfirm email and you are blocked from doing other user things

Actual
4. See message that asks to reconfirm email and you can do other user things

@sandlerben sandlerben added the bug label Oct 24, 2015
@aharelick
Copy link
Contributor

@sandlerben, @jondubin: How do people feel about having another decorator like @confirmed to put on top of routes that require it. Understandably, this may be a little excessive. I think the overlap between @login_required and something like @confirmed would be pretty large, but just wanted to gauge opinions.

@sandlerben
Copy link
Contributor Author

Could we create a better version of login_required and put it in decorators.py?

@jondubin
Copy link

How about we pass an argument into the decorator to indicate whether the acct needs to be confirmed or not?

@sandlerben
Copy link
Contributor Author

That's a good idea. Every endpoint that is login protected should also require confirmation except the confirm account endpoint.

@abhisuri97
Copy link
Contributor

Is this still an error? I just tried this in my app and the expected behavior is what is happening currently. I think that the following found in app/account/views.py takes care of the issue (or at least it should):

@account.before_app_request
def before_request():
    """Force user to confirm email before accessing login-required routes."""
    if current_user.is_authenticated() \
            and not current_user.confirmed \
            and request.endpoint[:8] != 'account.' \
            and request.endpoint != 'static':
        return redirect(url_for('account.unconfirmed'))


@account.route('/unconfirmed')
def unconfirmed():
    """Catch users with unconfirmed emails."""
    if current_user.is_anonymous() or current_user.confirmed:
        return redirect(url_for('main.index'))
    return render_template('account/unconfirmed.html')

@sandlerben
Copy link
Contributor Author

It's possible I fixed it without closing the issue. I'll check and update
this issue.

On Sun, Mar 20, 2016, 2:58 AM Abhinav Suri notifications@github.com wrote:

Is this still an error? I just tried this in my app and the expected
behavior is what is happening currently. I think that the following found
in app/account/views.py takes care of the issue (or at least it should):

@account.before_app_request
def before_request():
"""Force user to confirm email before accessing login-required routes."""
if current_user.is_authenticated()
and not current_user.confirmed
and request.endpoint[:8] != 'account.'
and request.endpoint != 'static':
return redirect(url_for('account.unconfirmed'))

@account.route('/unconfirmed')
def unconfirmed():
"""Catch users with unconfirmed emails."""
if current_user.is_anonymous() or current_user.confirmed:
return redirect(url_for('main.index'))
return render_template('account/unconfirmed.html')


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#17 (comment)

@abhisuri97
Copy link
Contributor

permission to close the issue? tested and it seems to be fixed.

@sandlerben
Copy link
Contributor Author

yes this looks fixed! sorry for the delayed response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants