Skip to content

Commit fcf2d22

Browse files
authored
Merge pull request #77 from OpenDash-Team/feature/owner-role
Customer and owner roles + demo accounts
2 parents 0d442f5 + 086d963 commit fcf2d22

5 files changed

Lines changed: 45 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ mv backend/sample-data backend/data
6565
Rename-Item backend/sample-data backend/data
6666
```
6767

68+
### Demo Accounts
69+
70+
The sample data has two accounts, both with the password `password123`:
71+
72+
| Email | Role |
73+
|---|---|
74+
| `customer@openeats.com` | `customer` |
75+
| `owner@openeats.com` | `owner` |
76+
77+
New registrations are always customers.
78+
6879
### Running the API
6980

7081
Start the application with:

‎backend/app/schemas/customer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from ..core.identifiers import generate_id
66

7-
CustomerRole = Literal["customer", "owner", "admin"]
7+
CustomerRole = Literal["customer", "owner"]
88

99

1010
class Customer(BaseModel):

‎backend/sample-data/customers.json‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
[]
1+
[
2+
{
3+
"id": "demoCustomer000000001",
4+
"name": "Demo Customer",
5+
"email": "customer@openeats.com",
6+
"hashedPassword": "$argon2id$v=19$m=65536,t=3,p=4$OVNGdn3qFR1JzPTh37pxHA$7Q+73S5XnEGfXxLu9ukB1ykduW9xi89GEmc3Il4jkk0",
7+
"telephone": null,
8+
"address": "3333 University Way, Kelowna, BC",
9+
"role": "customer",
10+
"isActive": true
11+
},
12+
{
13+
"id": "demoOwner000000000001",
14+
"name": "Demo Owner",
15+
"email": "owner@openeats.com",
16+
"hashedPassword": "$argon2id$v=19$m=65536,t=3,p=4$uJMwfg1M4n/eWtITM8qiMA$iS0myGXv/RwzsxgN7FZZ4+96KJgnKskIwOBPh5odEpY",
17+
"telephone": null,
18+
"address": null,
19+
"role": "owner",
20+
"isActive": true
21+
}
22+
]

‎backend/tests/test-data/customers.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,15 @@
1818
"address": null,
1919
"role": "customer",
2020
"isActive": false
21+
},
22+
{
23+
"id": "cust0000000000000owner",
24+
"name": "Olivia Owner",
25+
"email": "owner@example.com",
26+
"hashedPassword": "$argon2id$v=19$m=65536,t=3,p=4$g+rI/+OQz5FRaAHUMwBgAA$/qhCMrUnpOABJYM/iv/8WQEriYyoe6kd0hf7/0m7+gg",
27+
"telephone": null,
28+
"address": null,
29+
"role": "owner",
30+
"isActive": true
2131
}
2232
]

‎backend/tests/test_customer_endpoints.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_update_with_no_fields_returns_422(signed_in_client):
117117

118118

119119
def test_update_cannot_change_role(signed_in_client):
120-
response = signed_in_client.patch("/api/v1/customers/me", json={"name": "Alex", "role": "admin"})
120+
response = signed_in_client.patch("/api/v1/customers/me", json={"name": "Alex", "role": "owner"})
121121

122122
assert response.status_code == 422
123123
assert signed_in_client.get("/api/v1/customers/me").json()["role"] == "customer"

0 commit comments

Comments
 (0)