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