From 4832b5b9d2f26866c877eef71d459153e712d6a3 Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Fri, 9 Oct 2020 11:14:40 -0700 Subject: [PATCH 1/2] fixed updating template list on delete --- backend/api/routers/resources.py | 8 ++++---- frontend/src/components/images/ImageDetails.vue | 2 +- frontend/src/components/images/ImageList.vue | 6 ++---- frontend/src/store/modules/images.js | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/api/routers/resources.py b/backend/api/routers/resources.py index b89792ba..1d576e6f 100644 --- a/backend/api/routers/resources.py +++ b/backend/api/routers/resources.py @@ -6,18 +6,18 @@ router = APIRouter() -@router.get("/images/") +@router.get("/images/", dependencies=[Depends(get_active_user)]) def get_images(): return resources.get_images() -@router.get("/images/{image_id}") +@router.get("/images/{image_id}", dependencies=[Depends(get_active_user)]) def get_image(image_id): return resources.get_image(image_id) -@router.get("/images/{image_id}/pull") +@router.get("/images/{image_id}/pull", dependencies=[Depends(get_active_user)]) def pull_image(image_id): return resources.update_image(image_id) -@router.delete("/images/{image_id}") +@router.delete("/images/{image_id}", dependencies=[Depends(get_active_user)]) def delete_image(image_id): return resources.delete_image(image_id) \ No newline at end of file diff --git a/frontend/src/components/images/ImageDetails.vue b/frontend/src/components/images/ImageDetails.vue index e58da886..9deca044 100644 --- a/frontend/src/components/images/ImageDetails.vue +++ b/frontend/src/components/images/ImageDetails.vue @@ -97,7 +97,7 @@ Entrypoint - + {{ image.ContainerConfig.Entrypoint[0] }} diff --git a/frontend/src/components/images/ImageList.vue b/frontend/src/components/images/ImageList.vue index 4dde3f79..ee37b2ba 100644 --- a/frontend/src/components/images/ImageList.vue +++ b/frontend/src/components/images/ImageList.vue @@ -20,9 +20,7 @@ hide-details > - - Note: Image list will not update after an update or delete (WIP). - + View - + mdi-update diff --git a/frontend/src/store/modules/images.js b/frontend/src/store/modules/images.js index 5b279e09..86d8048b 100644 --- a/frontend/src/store/modules/images.js +++ b/frontend/src/store/modules/images.js @@ -22,7 +22,7 @@ const mutations = { state.images.push(image); }, removeImage(state, image) { - const idx = state.images.findIndex(x => x.id === image.id); + const idx = state.images.findIndex(x => x.Id === image.Id); if (idx < 0) { return; } From 0f3b5e500b44c7b335524242d9e0dbe02266025b Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Fri, 9 Oct 2020 11:41:20 -0700 Subject: [PATCH 2/2] added DISABLE_AUTH environment variable. Need to have frontend recognize it. --- backend/api/auth/auth.py | 8 +++++++- backend/api/settings.py | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/api/auth/auth.py b/backend/api/auth/auth.py index 88e7e389..4299f2c2 100644 --- a/backend/api/auth/auth.py +++ b/backend/api/auth/auth.py @@ -69,10 +69,16 @@ class UserTable(Base, SQLAlchemyBaseUserTable): UserDB, ) -get_active_user = fastapi_users.get_current_active_user +# get_active_user = fastapi_users.get_current_active_user get_auth_router = fastapi_users.get_auth_router get_password_hash = get_password_hash +async def get_active_user(): + DISABLE_AUTH = settings.DISABLE_AUTH + if DISABLE_AUTH == True: + return + else: + await fastapi_users.get_current_active_user() async def user_create(UD): await fastapi_users.db.create(UD) diff --git a/backend/api/settings.py b/backend/api/settings.py index 96ac1bbb..3f559276 100644 --- a/backend/api/settings.py +++ b/backend/api/settings.py @@ -13,8 +13,7 @@ class Settings(BaseSettings): ACCESS_TOKEN_EXPIRES = os.environ.get('ACCESS_TOKEN_EXPIRES', 15) REFRESH_TOKEN_EXPIRES = os.environ.get('REFRESH_TOKEN_EXPIRES', 1) SAME_SITE_COOKIES = os.environ.get('SAME_SITE_COOKIES', True) - - + DISABLE_AUTH = os.environ.get('DISABLE_AUTH', False) BASE_TEMPLATE_VARIABLES = [ {"variable": "!config", "replacement": "/yacht/AppData/Config"}, {"variable": "!data", "replacement": "/yacht/AppData/Data"},