giving admin permissions
This commit is contained in:
parent
aee68936d2
commit
c3210f2f5c
|
@ -21,7 +21,10 @@ export function isWhitelisted(email?: string) {
|
|||
}
|
||||
|
||||
// TODO: Before open sourcing, we should turn these into env vars
|
||||
export function isAdmin(email: string) {
|
||||
export function isAdmin(email?: string) {
|
||||
if (!email) {
|
||||
return false
|
||||
}
|
||||
return ENV_CONFIG.adminEmails.includes(email)
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ export const PROD_CONFIG: EnvConfig = {
|
|||
'iansphilips@gmail.com', // Ian
|
||||
'd4vidchee@gmail.com', // D4vid
|
||||
'federicoruizcassarino@gmail.com', // Fede
|
||||
'ingawei@gmail.com', //Inga
|
||||
],
|
||||
visibility: 'PUBLIC',
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
groupPayoutsByUser,
|
||||
Payout,
|
||||
} from '../../common/payouts'
|
||||
import { isManifoldId } from '../../common/envs/constants'
|
||||
import { isAdmin, isManifoldId } from '../../common/envs/constants'
|
||||
import { removeUndefinedProps } from '../../common/util/object'
|
||||
import { LiquidityProvision } from '../../common/liquidity-provision'
|
||||
import { APIError, newEndpoint, validate } from './api'
|
||||
|
@ -76,13 +76,14 @@ export const resolvemarket = newEndpoint(opts, async (req, auth) => {
|
|||
throw new APIError(404, 'No contract exists with the provided ID')
|
||||
const contract = contractSnap.data() as Contract
|
||||
const { creatorId, closeTime } = contract
|
||||
const user = await admin.auth().getUser(auth.uid)
|
||||
|
||||
const { value, resolutions, probabilityInt, outcome } = getResolutionParams(
|
||||
contract,
|
||||
req.body
|
||||
)
|
||||
|
||||
if (creatorId !== auth.uid && !isManifoldId(auth.uid))
|
||||
if (creatorId !== auth.uid && !isManifoldId(auth.uid) && !isAdmin())
|
||||
throw new APIError(403, 'User is not creator of contract')
|
||||
|
||||
if (contract.resolution) throw new APIError(400, 'Contract already resolved')
|
||||
|
|
|
@ -10,13 +10,15 @@ import { NumericContract, PseudoNumericContract } from 'common/contract'
|
|||
import { APIError, resolveMarket } from 'web/lib/firebase/api'
|
||||
import { BucketInput } from './bucket-input'
|
||||
import { getPseudoProbability } from 'common/pseudo-numeric'
|
||||
import { Row } from './layout/row'
|
||||
|
||||
export function NumericResolutionPanel(props: {
|
||||
isAdmin: boolean
|
||||
creator: User
|
||||
contract: NumericContract | PseudoNumericContract
|
||||
className?: string
|
||||
}) {
|
||||
const { contract, className } = props
|
||||
const { contract, className, isAdmin } = props
|
||||
const { min, max, outcomeType } = contract
|
||||
|
||||
const [outcomeMode, setOutcomeMode] = useState<
|
||||
|
@ -78,10 +80,20 @@ export function NumericResolutionPanel(props: {
|
|||
: 'btn-disabled'
|
||||
|
||||
return (
|
||||
<Col className={clsx('rounded-md bg-white px-8 py-6', className)}>
|
||||
<div className="mb-6 whitespace-nowrap text-2xl">Resolve market</div>
|
||||
<Col
|
||||
className={clsx(
|
||||
'relative w-full rounded-md bg-white px-8 py-6',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{isAdmin && (
|
||||
<span className="absolute right-4 top-4 rounded bg-red-200 p-1 text-xs text-red-600">
|
||||
ADMIN
|
||||
</span>
|
||||
)}
|
||||
<div className="whitespace-nowrap text-2xl">Resolve market</div>
|
||||
|
||||
<div className="mb-3 text-sm text-gray-500">Outcome</div>
|
||||
<div className="my-3 text-sm text-gray-500">Outcome</div>
|
||||
|
||||
<Spacer h={4} />
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ import { getProbability } from 'common/calculate'
|
|||
import { BinaryContract, resolution } from 'common/contract'
|
||||
|
||||
export function ResolutionPanel(props: {
|
||||
isAdmin: boolean
|
||||
creator: User
|
||||
contract: BinaryContract
|
||||
className?: string
|
||||
}) {
|
||||
const { contract, className } = props
|
||||
const { contract, className, isAdmin } = props
|
||||
|
||||
// const earnedFees =
|
||||
// contract.mechanism === 'dpm-2'
|
||||
|
@ -66,7 +67,12 @@ export function ResolutionPanel(props: {
|
|||
: 'btn-disabled'
|
||||
|
||||
return (
|
||||
<Col className={clsx('rounded-md bg-white px-8 py-6', className)}>
|
||||
<Col className={clsx('relative rounded-md bg-white px-8 py-6', className)}>
|
||||
{isAdmin && (
|
||||
<span className="absolute right-4 top-4 rounded bg-red-200 p-1 text-xs text-red-600">
|
||||
ADMIN
|
||||
</span>
|
||||
)}
|
||||
<div className="mb-6 whitespace-nowrap text-2xl">Resolve market</div>
|
||||
|
||||
<div className="mb-3 text-sm text-gray-500">Outcome</div>
|
||||
|
|
|
@ -143,9 +143,17 @@ export function ContractPageSidebar(props: {
|
|||
))}
|
||||
{allowResolve &&
|
||||
(isNumeric || isPseudoNumeric ? (
|
||||
<NumericResolutionPanel creator={user} contract={contract} />
|
||||
<NumericResolutionPanel
|
||||
isAdmin={isAdmin}
|
||||
creator={user}
|
||||
contract={contract}
|
||||
/>
|
||||
) : (
|
||||
<ResolutionPanel creator={user} contract={contract} />
|
||||
<ResolutionPanel
|
||||
isAdmin={isAdmin}
|
||||
creator={user}
|
||||
contract={contract}
|
||||
/>
|
||||
))}
|
||||
</Col>
|
||||
) : null
|
||||
|
|
Loading…
Reference in New Issue
Block a user