Comments (2)
I can't seem to reproduce the issue with the current version (there are also pytests for that feature). Maybe it has something to do with the Flask-Login
integration? Have you set the user_loader
for Flask-Login? Something like:
@login_manager.user_loader
def load_user(user_id):
return User.query.filter_by(id=user_id).first()
I'd also recommend returning self.id
for the User.get_id
method instead of self.name
.
from flask-authorize.
Yes, I already set user_loader
.
I change User.get_id
and user_loader
as you suggested:
class User(db.Model):
def get_id(self):
return self.id
@login_manager.user_loader
def load_user(user_id):
flask.g.user = (
models
.User
.query
.filter(models.User.id == user_id)
.options(sqlalchemy.orm.joinedload(models.User.roles))
.first()
)
return flask.g.user
But the problem persists.
Well, it seems there's some complication down the road somewhere in my system.
For now I'll use the explicit method.
Thank you for your help.
from flask-authorize.
Related Issues (20)
- Add documentation and testing for setting default allowances/restrictions.
- Wildcard allowances don't permit all as the documentation states it should. HOT 4
- Detect the use of Restrictions/Allowances mixins and provide default fail-safe for users that aren't tied specifically to a role or group.
- with Flask-Authorize I can achieve a roles and level permission for each service?
- RestrictionMixin does not work as expected HOT 2
- VARCHAR requires a length on dialect mysql HOT 1
- Usage with factory pattern HOT 2
- Owner ID always null in DB HOT 4
- Unexpected Anonymous user behavior HOT 6
- NameError: name 'authorize' is not defined HOT 1
- Unable to add a second user_id relationship HOT 2
- user_id can only be an Integer HOT 1
- question about adding special permission for single user/group HOT 6
- Need to be able to specify the names of specific tables HOT 4
- type object 'Model' has no attribute '_decl_class_registry' HOT 4
- Flask-SQLAlchemy Dependency needed? HOT 1
- fix/new group add
- Can't use the same function name in different classes
- Users unrelated to groups or roles are allowed by the Authorizer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-authorize.