mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
retype AdminPkgs since PkgRecord id as key will not yet exist
This commit is contained in:
@@ -329,7 +329,7 @@ getVersionPlatform pkgId arches = do
|
||||
pure v
|
||||
pure $ entityVal <$> vps
|
||||
|
||||
getAllowedPkgs :: (Monad m, MonadIO m) => PkgRecordId -> AdminId -> ReaderT SqlBackend m [AdminPkgs]
|
||||
getAllowedPkgs :: (Monad m, MonadIO m) => PkgId -> AdminId -> ReaderT SqlBackend m [AdminPkgs]
|
||||
getAllowedPkgs pkgId adminId = do
|
||||
pkgs <- select $ do
|
||||
p <- from $ table @AdminPkgs
|
||||
|
||||
@@ -168,7 +168,7 @@ postCheckPkgAuthR pkgId = do
|
||||
else if authorized && newPkg
|
||||
-- if pkg is whitelisted and a new upload, add as authorized for this admin user
|
||||
then do
|
||||
runDB $ insert_ (AdminPkgs (AdminKey name) (PkgRecordKey pkgId))
|
||||
runDB $ insert_ (AdminPkgs (AdminKey name) pkgId)
|
||||
sendResponseText status200 "User authorized to upload this package."
|
||||
else sendResponseText status401 "User not authorized to upload this package."
|
||||
else sendResponseText status500 "Package does not belong on this registry."
|
||||
|
||||
@@ -256,12 +256,12 @@ areRegexMatchesEqual textMap (PackageDevice regexMap) =
|
||||
case MM.lookup key textMap of
|
||||
val -> or $ regexMatch regexPattern <$> val
|
||||
|
||||
checkAdminAllowedPkgs :: PkgId -> Text -> Handler (Bool, Bool) -- (exists, new)
|
||||
checkAdminAllowedPkgs :: PkgId -> Text -> Handler (Bool, Bool) -- (authorized, newPkg)
|
||||
checkAdminAllowedPkgs pkgId adminId = do
|
||||
-- if pkg does not exist yet, allow, because authorized by whitelist
|
||||
pkg <- runDB $ getPkg (PkgRecordKey pkgId)
|
||||
if length pkg > 0
|
||||
then do
|
||||
res <- runDB $ getAllowedPkgs (PkgRecordKey pkgId) (AdminKey adminId)
|
||||
res <- runDB $ getAllowedPkgs pkgId (AdminKey adminId)
|
||||
pure $ if length res > 0 then (True, False) else (False, False)
|
||||
else pure (True, True)
|
||||
@@ -155,7 +155,7 @@ Admin
|
||||
|
||||
AdminPkgs
|
||||
admin AdminId
|
||||
pkgId PkgRecordId
|
||||
pkgId PkgId
|
||||
UniqueAdminPkg pkgId admin
|
||||
|
||||
Upload
|
||||
|
||||
Reference in New Issue
Block a user