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

Switch from g.user to current_user #154

Closed
jace opened this issue Nov 21, 2017 · 2 comments
Closed

Switch from g.user to current_user #154

jace opened this issue Nov 21, 2017 · 2 comments

Comments

@jace
Copy link
Member

jace commented Nov 21, 2017

Coaster currently expects a g.user entity in load_models. If the implementation for hasgeek/baseframe#80 (CRUD views) is moved to Coaster, that will add a second reference to g.user.

However, hasgeek/flask-lastuser#24 proposes replacing g.user with a current_user proxy, which must be explicitly imported. This is a problem because Flask-Lastuser depends on Coaster. Coaster can't import from Flask-Lastuser.

We can get around this cyclic dependency by making a choice:

  1. Stick with g.user. The problems it causes will remain, such as the possibility of an app's before_request handler attempting to access it before it is set.

  2. Coaster should add a dependency on Flask-Login and import current_user from there. Flask-Lastuser will need to plugin to Flask-Login and replace the user loading mechanism there.

  3. Coaster should provide its own current_user proxy, but allow the backing implementation to be replaced (process-wide). Importing Flask-Lastuser into the same process will automatically apply this replacement.

@jace
Copy link
Member Author

jace commented Nov 21, 2017

Choice 1 is clearly not viable any further. Flask-Login makes assumptions about users that aren't necessarily compatible with Lastuser, so we should not add a dependency to it.

If we take choice 3, we need to demonstrate that Coaster's current_user proxy can be compatible with both Flask-Login and Flask-Lastuser.

@jace
Copy link
Member Author

jace commented Nov 24, 2017

Discussion on implementation details is in #155.

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

No branches or pull requests

1 participant