Fix/insert admin (#144)

* change insert to do nothing on conflict

* misc protocol updates
This commit is contained in:
Lucy
2024-07-11 17:27:29 -04:00
committed by GitHub
parent 4c42c177e8
commit 86dad04188
2 changed files with 10 additions and 4 deletions

View File

@@ -35,7 +35,13 @@ NONE
#### Query Params #### Query Params
- (Required) "eos-version-compat": EmverRange specifying what versions of the OS that pack the packages are valid response items - (Legacy) "eos-version-compat": EmverRange specifying what versions of the OS that pack the packages are valid response items
- (Required) "os.compat": EmverRange specifying what versions of the OS that pack the packages are valid response items
- (Required): "hardware.ram":
- (Required): "hardware.device":
- (Required): "hardware.arch":
- (Required): "os.arch":
- (Legacy): "arch":
- (Optional) "ids": json array of package ids - (Optional) "ids": json array of package ids
- (Optional) "category": string representing - (Optional) "category": string representing
- (Optional) "page": which page of the index you want (NOTE: starts at 1) (Default: 1) - (Optional) "page": which page of the index you want (NOTE: starts at 1) (Default: 1)
@@ -63,7 +69,7 @@ NONE
// name of dependency // name of dependency
"title": "<STRING>", "title": "<STRING>",
// icon of dependency // icon of dependency
"icon": "<DATAURL>" "icon": "<URL>"
}, },
... ...
} }

View File

@@ -99,7 +99,7 @@ import Network.HTTP.Types.Status (status401)
import Yesod (getsYesod) import Yesod (getsYesod)
import Settings (AppSettings(whitelist)) import Settings (AppSettings(whitelist))
import Network.HTTP.Types (status200) import Network.HTTP.Types (status200)
import Database.Persist (insert_) import Database.Persist (insert_, insertBy)
import Yesod (lookupPostParam) import Yesod (lookupPostParam)
import Data.Maybe (isNothing) import Data.Maybe (isNothing)
@@ -307,7 +307,7 @@ checkAdminAuthUpload pkgId = do
else if authorized && newPkg else if authorized && newPkg
-- if pkg is whitelisted and a new upload, add as authorized for this admin user -- if pkg is whitelisted and a new upload, add as authorized for this admin user
then do then do
runDB $ insert_ (AdminPkgs (AdminKey name) pkgId) _ <- runDB $ insertBy (AdminPkgs (AdminKey name) pkgId)
pure name pure name
else sendResponseText status401 "User not authorized to upload this package." else sendResponseText status401 "User not authorized to upload this package."
else sendResponseText status401 "Package does not belong on this registry." else sendResponseText status401 "Package does not belong on this registry."