I'm new to flask, but moderately versed in python - I have a flash application that uses a flash drive to authenticate the user. I would like to add some additional features to the login process. In particular, I need to save the auth_token user (which I configured as a one-time token) in db when I log in and delete it when I log out. The problem arises because flash protection (as far as I know) does not reveal the registration mechanism directly to the developer. As far as I can tell from this code, it imports a login flag that uses the login_user function.
I started by trying to override this function by importing flask.ext.login (which I usually didn't need to do) and overriding the function as follows:
import flask.ext.login as a def new_login_user(): ...copy of existing function goes here... ...Plus new stuff with current_user.get_auth_token()... a.login_user = new_login_user
however, I got into all kinds of namespace problems, and it seems like this is a really ugly way to do this.
I thought there might be a way to do this with a decorator, but I'm new to the bulb and haven't used decorators in many ways.
Any ideas on what could be the best way to get closer to this? for context, I want auth_token in db because I need to pass website authentication to another process that also accesses db. Another process is an API server using websockets. I do not want to combine processes.
python flask flask-security
domoarrigato
source share