Skip to content

Commit e27d74a

Browse files
committed
Gate inventory on auth
1 parent 63f64ad commit e27d74a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ To avoid wiping your local db every time you rebuild, make sure the migrate line
3030

3131
### MVP
3232

33-
- gate inventory on auth
3433
- persist data across deploys
3534

3635
### Nice to have

inventory/schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from graphql_relay import from_global_id
77
from .models import Product, InventoryItem, QuantitativeUnit
88
from core.models import User
9-
9+
from graphql_jwt.decorators import login_required
1010

1111
class ProductType(DjangoObjectType):
1212
class Meta:
@@ -66,8 +66,10 @@ def resolve_products(self, info, **kwargs):
6666
def resolve_units(self, info, **kwargs):
6767
return QuantitativeUnit.objects.all().order_by('name')
6868

69+
@login_required
6970
def resolve_inventory_items(self, info, **kwargs):
70-
return InventoryItem.objects.all().order_by('expiration_date')
71+
user = info.context.user
72+
return InventoryItem.objects.filter(person=user).order_by('expiration_date')
7173

7274

7375
class UpdateItemQuantity(relay.ClientIDMutation):

0 commit comments

Comments
 (0)