Search code examples
flaskpython-social-auth

Why my Flask application can't create new user using Python Social Auth?


I am using python-social-auth package, and it has rather strange behavior, that is, I can login using existing gmail account already signup in the database, but I can't register new user.

Actually, this is a dockerize Flask application (in app.py). If I am not using supervisord, all Python Social Auth behavior works fine. That's mean, I directly call python app.py, instead of configuring it to run by supervisord in supervisord.conf.

But if I use supervisord, new user will not get registered. Application will be directed to login page.

NOTE: on the other hand, I am trying to rewrite social implementation by using Flask-OAuth.


Solution

  • Finally, I found the bug. These are code fix for custom pipeline for confirmed oauth process:

    def pipeline_oauth_confirmed(backend, user, response, *args, **kwargs):
       user.active = True
       user.confirmed_at = datetime.now()
       db_session.commit()
    

    As the app need to have user.active=True before it logged in the user, the user wont' be logged in. I omitted the db_session.commit() call. Once that added, it works!