mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
check for backwards compatibility
This commit is contained in:
@@ -53,7 +53,7 @@ import Data.HashMap.Internal.Strict (
|
|||||||
import Data.String.Interpolate.IsString (
|
import Data.String.Interpolate.IsString (
|
||||||
i,
|
i,
|
||||||
)
|
)
|
||||||
import Data.Text (toLower, splitOn, unpack)
|
import Data.Text (toLower, splitOn)
|
||||||
import Dhall (
|
import Dhall (
|
||||||
Encoder (embed),
|
Encoder (embed),
|
||||||
FromDhall (..),
|
FromDhall (..),
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ import Database.Esqueleto.Experimental (
|
|||||||
(:&) (..),
|
(:&) (..),
|
||||||
(==.),
|
(==.),
|
||||||
(^.),
|
(^.),
|
||||||
(||.),
|
(||.), not_,
|
||||||
)
|
)
|
||||||
import Database.Persist qualified as P
|
import Database.Persist qualified as P
|
||||||
import Database.Persist.Postgresql (
|
import Database.Persist.Postgresql (
|
||||||
@@ -96,7 +96,7 @@ import Model (
|
|||||||
VersionRecordNumber,
|
VersionRecordNumber,
|
||||||
VersionRecordPkgId,
|
VersionRecordPkgId,
|
||||||
VersionRecordTitle,
|
VersionRecordTitle,
|
||||||
VersionRecordUpdatedAt, PkgRecordHidden, VersionPlatformRam
|
VersionRecordUpdatedAt, PkgRecordHidden, VersionPlatformRam, PkgRecordUpdatedAt
|
||||||
),
|
),
|
||||||
Key (unPkgRecordKey),
|
Key (unPkgRecordKey),
|
||||||
PkgCategory,
|
PkgCategory,
|
||||||
@@ -345,3 +345,12 @@ getPkg pkgId = do
|
|||||||
where_ $ p ^. PkgRecordId ==. val pkgId
|
where_ $ p ^. PkgRecordId ==. val pkgId
|
||||||
pure p
|
pure p
|
||||||
pure $ entityVal <$> pkg
|
pure $ entityVal <$> pkg
|
||||||
|
|
||||||
|
getPkgNew:: (Monad m, MonadIO m) => PkgRecordId -> ReaderT SqlBackend m [PkgRecord]
|
||||||
|
getPkgNew pkgId = do
|
||||||
|
pkg <- select $ do
|
||||||
|
p <- from $ table @PkgRecord
|
||||||
|
where_ $ p ^. PkgRecordId ==. val pkgId
|
||||||
|
where_ $ isNothing $ p ^. PkgRecordUpdatedAt
|
||||||
|
pure p
|
||||||
|
pure $ entityVal <$> pkg
|
||||||
@@ -18,7 +18,7 @@ import Data.String.Interpolate.IsString (
|
|||||||
import Data.Text qualified as T
|
import Data.Text qualified as T
|
||||||
import Data.Text.Lazy qualified as TL
|
import Data.Text.Lazy qualified as TL
|
||||||
import Data.Text.Lazy.Builder qualified as TB
|
import Data.Text.Lazy.Builder qualified as TB
|
||||||
import Database.Queries (fetchAllPkgVersions, getVersionPlatform, getAllowedPkgs, getPkg)
|
import Database.Queries (fetchAllPkgVersions, getVersionPlatform, getAllowedPkgs, getPkg, getPkgNew)
|
||||||
import Foundation
|
import Foundation
|
||||||
import Lib.PkgRepository (
|
import Lib.PkgRepository (
|
||||||
PkgRepo,
|
PkgRepo,
|
||||||
@@ -271,10 +271,13 @@ checkAdminAllowedPkgs :: PkgId -> Text -> Handler (Bool, Bool) -- (authorized, n
|
|||||||
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)
|
||||||
|
pkgCreated <- runDB $ getPkgNew (PkgRecordKey pkgId)
|
||||||
if length pkg > 0
|
if length pkg > 0
|
||||||
then do
|
then do
|
||||||
res <- runDB $ getAllowedPkgs 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 if length pkgCreated > 0
|
||||||
|
then pure (True, True)
|
||||||
else pure (True, True)
|
else pure (True, True)
|
||||||
|
|
||||||
checkAdminAuth :: PkgId -> Handler (Bool, Text)
|
checkAdminAuth :: PkgId -> Handler (Bool, Text)
|
||||||
|
|||||||
Reference in New Issue
Block a user