diff --git a/api/advent22_api/routers/admin.py b/api/advent22_api/routers/admin.py
index 93b1ca0..c2edc32 100644
--- a/api/advent22_api/routers/admin.py
+++ b/api/advent22_api/routers/admin.py
@@ -7,16 +7,16 @@ from ..core.calendar_config import CalendarConfig, get_calendar_config
from ..core.config import Config, get_config
from ..core.depends import shuffle_solution
from ..core.settings import SETTINGS
-from ._security import require_admin
+from ._security import user_is_admin
router = APIRouter(prefix="/admin", tags=["admin"])
-@router.get("/check")
-async def check_admin(
- _: None = Depends(require_admin),
+@router.get("/is_admin")
+async def is_admin(
+ is_admin: bool = Depends(user_is_admin),
) -> bool:
- return True
+ return is_admin
class ConfigModel(BaseModel):
diff --git a/ui/src/App.vue b/ui/src/App.vue
index 28226b3..8589e79 100644
--- a/ui/src/App.vue
+++ b/ui/src/App.vue
@@ -1,17 +1,18 @@
-
- Adventskalender {{ date }}
-
+ Adventskalender
Der Gelöt
-
@@ -33,18 +34,7 @@ import DoorMapEditor from "./components/DoorMapEditor.vue";
},
})
export default class extends Vue {
- private visible_days = 0;
- date = "";
-
- public mounted() {
- this.$advent22
- .api_get("days/date")
- .then((date: string) => (this.date = date));
-
- this.$advent22
- .api_get("days/visible_days")
- .then((visible_days: number) => (this.visible_days = visible_days));
- }
+ public is_admin = false;
}
diff --git a/ui/src/components/AdminButton.vue b/ui/src/components/AdminButton.vue
index 629c31e..54608ac 100644
--- a/ui/src/components/AdminButton.vue
+++ b/ui/src/components/AdminButton.vue
@@ -1,5 +1,5 @@
-
+
("admin/is_admin")
+ .then((is_admin) => this.$emit("update:modelValue", is_admin));
+ }
}
diff --git a/ui/src/components/LoginModal.vue b/ui/src/components/LoginModal.vue
index 1669b12..47e06b7 100644
--- a/ui/src/components/LoginModal.vue
+++ b/ui/src/components/LoginModal.vue
@@ -62,6 +62,7 @@ import BulmaButton from "./bulma/Button.vue";
components: {
BulmaButton,
},
+ emits: ["submit"],
})
export default class extends Vue {
public active = false;
@@ -95,6 +96,7 @@ export default class extends Vue {
public submit() {
this.$advent22.set_api_auth(this.username, this.password);
+ this.$emit("submit");
this.set_active(false);
}
}