pallets-eco/flask-social

Improper Redirect

Closed this issue · 1 comments

Tested logging a user into facebook, twitter & google.

Redirects after registration are not working correctly:

The login is successful and redirects back to the application at the standard /login/ endpoint. From here it redirects to /login and then to /. Both SECURITY_POST_LOGIN and SOCIAL_CONNECT_ALLOW_VIEW are set to /profile so it should be redirecting there.

I'm using this code for the registration view:

@login_failed.connect_via(app)
def on_login_failed(sender, provider, oauth_response):
    connection_values = get_connection_values_from_oauth_response(provider, oauth_response)
    ds = security
    email = connection_values['email']
    user = ds.datastore.create_user(
        email=email,
        username=email,
        password=create_random_password()
    )
    ds.datastore.commit()
    connection_values['user_id'] = user.id
    connect_handler(connection_values, provider)
    login_user(user)
    db.session.commit()
    return render_template('profile.html', user=user)

I can see that the user is added to the database and the connection is made. The redirect fails to work.

I have a feeling this might be happening due to #37 as I'm using the reauth branch.