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 v
|
||||||
pure $ entityVal <$> vps
|
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
|
getAllowedPkgs pkgId adminId = do
|
||||||
pkgs <- select $ do
|
pkgs <- select $ do
|
||||||
p <- from $ table @AdminPkgs
|
p <- from $ table @AdminPkgs
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ postCheckPkgAuthR 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) (PkgRecordKey pkgId))
|
runDB $ insert_ (AdminPkgs (AdminKey name) pkgId)
|
||||||
sendResponseText status200 "User authorized to upload this package."
|
sendResponseText status200 "User authorized to upload this package."
|
||||||
else sendResponseText status401 "User not 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."
|
else sendResponseText status500 "Package does not belong on this registry."
|
||||||
@@ -207,7 +207,7 @@ postPkgUploadR = do
|
|||||||
if authorized
|
if authorized
|
||||||
then do
|
then do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
runDB $ insert_ (Upload (AdminKey name) (PkgRecordKey packageManifestId) packageManifestVersion now)
|
runDB $ insert_ (Upload (AdminKey name) (PkgRecordKey packageManifestId)packageManifestVersion now)
|
||||||
else sendResponseText status401 "User not 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."
|
else sendResponseText status500 "Package does not belong on this registry."
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -256,12 +256,12 @@ areRegexMatchesEqual textMap (PackageDevice regexMap) =
|
|||||||
case MM.lookup key textMap of
|
case MM.lookup key textMap of
|
||||||
val -> or $ regexMatch regexPattern <$> val
|
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
|
checkAdminAllowedPkgs pkgId adminId = do
|
||||||
-- if pkg does not exist yet, allow, because authorized by whitelist
|
-- if pkg does not exist yet, allow, because authorized by whitelist
|
||||||
pkg <- runDB $ getPkg (PkgRecordKey pkgId)
|
pkg <- runDB $ getPkg (PkgRecordKey pkgId)
|
||||||
if length pkg > 0
|
if length pkg > 0
|
||||||
then do
|
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)
|
pure $ if length res > 0 then (True, False) else (False, False)
|
||||||
else pure (True, True)
|
else pure (True, True)
|
||||||
@@ -155,7 +155,7 @@ Admin
|
|||||||
|
|
||||||
AdminPkgs
|
AdminPkgs
|
||||||
admin AdminId
|
admin AdminId
|
||||||
pkgId PkgRecordId
|
pkgId PkgId
|
||||||
UniqueAdminPkg pkgId admin
|
UniqueAdminPkg pkgId admin
|
||||||
|
|
||||||
Upload
|
Upload
|
||||||
|
|||||||
Reference in New Issue
Block a user