Skip to content

Commit 3de5e48

Browse files
committed
Update python/HOC2023/scene4.md
1 parent 32303f6 commit 3de5e48

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

python/HOC2023/scene4.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
### @flyoutOnly true
2+
### @hideIteration false
3+
### @explicitHints true
4+
5+
# Scene4
6+
7+
## Step 1
8+
# Smart Doorlock
9+
10+
We've discovered a significant problem with the door lock system. Right now, anyone can see the event logs, which is a big privacy and security concern. To fix this issue, we need to update the code so that only administrators have access to the event logs.
11+
12+
The `permission_group()` function takes one parameter which defines which permission group it's being compared to.
13+
14+
Valid permission groups are:
15+
- `anyone`
16+
- `user`
17+
- `admin`
18+
19+
```python
20+
# CODE EXAMPLE - YOU CAN NOT EDIT HERE
21+
# RUN IT TO SEE WHAT HAPPENS
22+
23+
while human_detect():
24+
if user_authorized():
25+
check_user_permissions()
26+
if user_permissions() == permission_group("anyone"):
27+
enable_log_viewing()
28+
else:
29+
disable_log_viewing()
30+
```
31+
32+
---
33+
34+
## Step 2
35+
# Activity:
36+
37+
Change the setting of the `permission_group()` function to the right permission setting, which is `admin`
38+
39+
```python
40+
# code here
41+
42+
while human_detect():
43+
if user_authorized():
44+
check_user_permissions()
45+
if user_permissions() == permission_group("anyone"):
46+
enable_log_viewing()
47+
else:
48+
disable_log_viewing()
49+
```
50+
51+
---
52+

0 commit comments

Comments
 (0)