mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Refactor repeated auth errors
This commit is contained in:
parent
f8884ab93e
commit
af11737b48
@ -41,6 +41,8 @@ SUBPAGE_PERMS = {
|
||||
"webhooks": EnumPermissionsServer.CONFIG,
|
||||
}
|
||||
|
||||
SCHEDULE_AUTH_ERROR_URL = "/panel/error?error=Unauthorized access To Schedules"
|
||||
|
||||
|
||||
class PanelHandler(BaseHandler):
|
||||
def get_user_roles(self) -> t.Dict[str, list]:
|
||||
@ -1147,7 +1149,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]:
|
||||
if not superuser:
|
||||
self.redirect("/panel/error?error=Unauthorized access To Schedules")
|
||||
self.redirect(SCHEDULE_AUTH_ERROR_URL)
|
||||
return
|
||||
|
||||
template = "panel/server_schedule_edit.html"
|
||||
@ -1245,7 +1247,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if not EnumPermissionsServer.SCHEDULE in page_data["user_permissions"]:
|
||||
if not superuser:
|
||||
self.redirect("/panel/error?error=Unauthorized access To Schedules")
|
||||
self.redirect(SCHEDULE_AUTH_ERROR_URL)
|
||||
return
|
||||
|
||||
template = "panel/server_schedule_edit.html"
|
||||
@ -1317,7 +1319,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if EnumPermissionsServer.BACKUP not in page_data["user_permissions"]:
|
||||
if not superuser:
|
||||
self.redirect("/panel/error?error=Unauthorized access To Schedules")
|
||||
self.redirect(SCHEDULE_AUTH_ERROR_URL)
|
||||
return
|
||||
template = "panel/server_backup_edit.html"
|
||||
|
||||
@ -1376,7 +1378,7 @@ class PanelHandler(BaseHandler):
|
||||
|
||||
if EnumPermissionsServer.BACKUP not in page_data["user_permissions"]:
|
||||
if not superuser:
|
||||
self.redirect("/panel/error?error=Unauthorized access To Schedules")
|
||||
self.redirect(SCHEDULE_AUTH_ERROR_URL)
|
||||
return
|
||||
template = "panel/server_backup_edit.html"
|
||||
|
||||
|
@ -50,6 +50,7 @@ BASIC_BACKUP_PATCH_SCHEMA = {
|
||||
"minProperties": 1,
|
||||
}
|
||||
ID_MISMATCH = "Server ID backup server ID different"
|
||||
GENERAL_AUTH_ERROR = "Authorization Error"
|
||||
|
||||
|
||||
class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
@ -81,7 +82,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
self.finish_json(200, backup_conf)
|
||||
@ -114,7 +115,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
|
||||
@ -156,7 +157,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
backup_config = self.controller.management.get_backup_config(backup_id)
|
||||
@ -330,7 +331,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
if backup_conf["server_id"]["server_id"] != server_id:
|
||||
@ -356,7 +357,7 @@ class ApiServersServerBackupsBackupIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
self.controller.management.update_backup_config(backup_id, data)
|
||||
@ -392,7 +393,7 @@ class ApiServersServerBackupsBackupFilesIndexHandler(BaseApiHandler):
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Authorization Error",
|
||||
"error_data": GENERAL_AUTH_ERROR,
|
||||
},
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user