mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
move is_superuser and is_active to base User
This commit is contained in:
@@ -8,6 +8,7 @@ ChangeLog
|
||||
0.2.9
|
||||
-----
|
||||
- Rename `fastapi_admin.models.User` to `fastapi_admin.models.AbstractUser`.
|
||||
- Move `is_superuser` and `is_active` to base `AbstractUser`.
|
||||
|
||||
0.2.8
|
||||
-----
|
||||
|
||||
@@ -114,8 +114,7 @@ for reference.
|
||||
|
||||
### Builtin Auth And Permissions Control
|
||||
|
||||
You should inherit `fastapi_admin.models.AbstractUser` and add you own fields,must contains
|
||||
`is_active` and `is_superuser`.
|
||||
You should inherit `fastapi_admin.models.AbstractUser` and add extra fields.
|
||||
|
||||
```python
|
||||
from fastapi_admin.models import AbstractUser
|
||||
|
||||
@@ -9,8 +9,6 @@ from .enums import ProductType, Status
|
||||
|
||||
class User(AbstractUser):
|
||||
last_login = fields.DatetimeField(description="Last Login", default=datetime.datetime.now)
|
||||
is_active = fields.BooleanField(default=True, description="Is Active")
|
||||
is_superuser = fields.BooleanField(default=False, description="Is SuperUser")
|
||||
avatar = fields.CharField(max_length=200, default="")
|
||||
intro = fields.TextField(default="")
|
||||
created_at = fields.DatetimeField(auto_now_add=True)
|
||||
|
||||
@@ -8,6 +8,8 @@ class AbstractUser(Model):
|
||||
password = fields.CharField(
|
||||
max_length=200, description="Will auto hash with raw password when change"
|
||||
)
|
||||
is_active = fields.BooleanField(default=True,)
|
||||
is_superuser = fields.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
Reference in New Issue
Block a user