diff --git a/lib/new-admin/middlewares/context.js b/lib/new-admin/middlewares/context.js index 70e7d62f..c955bb49 100644 --- a/lib/new-admin/middlewares/context.js +++ b/lib/new-admin/middlewares/context.js @@ -20,7 +20,6 @@ const buildApolloContext = async ({ req, res }) => { req.session.user.role = user.role res.set('lamassu_role', user.role) - res.cookie('pazuz_operatoridentifier', base64.encode(user.username)) res.set('Access-Control-Expose-Headers', 'lamassu_role') return { req, res } diff --git a/new-lamassu-admin/.env b/new-lamassu-admin/.env index 153fab2c..e666d42d 100644 --- a/new-lamassu-admin/.env +++ b/new-lamassu-admin/.env @@ -2,4 +2,3 @@ SKIP_PREFLIGHT_CHECK=true HTTPS=true REACT_APP_TYPE_CHECK_SANCTUARY=false PORT=3001 -REACT_APP_BUILD_TARGET=LAMASSU diff --git a/new-lamassu-admin/package.json b/new-lamassu-admin/package.json index bd8aaa49..e6e554a7 100644 --- a/new-lamassu-admin/package.json +++ b/new-lamassu-admin/package.json @@ -92,9 +92,7 @@ "analyze": "source-map-explorer 'build/static/js/*.js'", "test": "react-scripts test", "eject": "react-scripts eject", - "postinstall": "patch-package", - "lamassu": "REACT_APP_BUILD_TARGET=LAMASSU react-scripts start", - "pazuz": "REACT_APP_BUILD_TARGET=PAZUZ react-scripts start" + "postinstall": "patch-package" }, "browserslist": { "production": [ diff --git a/new-lamassu-admin/src/index.js b/new-lamassu-admin/src/index.js index 8272c102..638af18d 100644 --- a/new-lamassu-admin/src/index.js +++ b/new-lamassu-admin/src/index.js @@ -2,30 +2,10 @@ import React from 'react' import ReactDOM from 'react-dom' import App from './App' -import * as serviceWorker from './serviceWorker' -function checkBuildTarget() { - const buildTarget = process.env.REACT_APP_BUILD_TARGET - - if (buildTarget !== 'LAMASSU' && buildTarget !== 'PAZUZ') { - return Promise.reject( - new Error('No such build target: ' + process.env.REACT_APP_BUILD_TARGET) - ) - } - - return Promise.resolve() -} - -checkBuildTarget().then(() => - ReactDOM.render( - - - , - document.getElementById('root') - ) +ReactDOM.render( + + + , + document.getElementById('root') ) - -// If you want your app to work offline and load faster, you can change -// unregister() to register() below. Note this comes with some pitfalls. -// Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister() diff --git a/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.js b/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.js deleted file mode 100644 index b9601108..00000000 --- a/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.js +++ /dev/null @@ -1,258 +0,0 @@ -import { useQuery } from '@apollo/react-hooks' -import { Paper } from '@material-ui/core' -import { makeStyles } from '@material-ui/core/styles' -import BigNumber from 'bignumber.js' -import classnames from 'classnames' -import gql from 'graphql-tag' -import * as R from 'ramda' -import React, { useContext } from 'react' - -import AppContext from 'src/AppContext' -import TitleSection from 'src/components/layout/TitleSection' -import { H3, Info2, Label2, Label3, P } from 'src/components/typography' -import { ReactComponent as BitcoinLogo } from 'src/styling/logos/icon-bitcoin-colour.svg' -import { ReactComponent as BitcoinCashLogo } from 'src/styling/logos/icon-bitcoincash-colour.svg' -import { ReactComponent as DashLogo } from 'src/styling/logos/icon-dash-colour.svg' -import { ReactComponent as EthereumLogo } from 'src/styling/logos/icon-ethereum-colour.svg' -import { ReactComponent as LitecoinLogo } from 'src/styling/logos/icon-litecoin-colour.svg' -import { ReactComponent as ZCashLogo } from 'src/styling/logos/icon-zcash-colour.svg' -import { numberToFiatAmount, numberToCryptoAmount } from 'src/utils/number' - -import styles from './ATMWallet.styles' - -const useStyles = makeStyles(styles) - -const GET_OPERATOR_BY_USERNAME = gql` - query operatorByUsername($username: String) { - operatorByUsername(username: $username) { - id - entityId - name - fiatBalances - cryptoBalances - machines - joined - assets - preferredFiatCurrency - contactInfo { - name - email - } - fundings { - id - origin - destination - fiatAmount - fiatBalanceAfter - fiatCurrency - created - status - description - } - } - } -` - -const CHIPS_PER_ROW = 6 - -const Assets = ({ balance, wallets, currency }) => { - const classes = useStyles({ numberOfChips: CHIPS_PER_ROW }) - - const walletFiatSum = R.sum(R.map(it => it.fiatValue, wallets)) - const totalValue = BigNumber(balance) - .plus(walletFiatSum) - .toNumber() - - return ( -
-
-

Available balance

-
- - {numberToFiatAmount(balance)} - - - {R.toUpper(currency)} - -
-
- + -
-

Total balance in wallets

-
- - {numberToFiatAmount(walletFiatSum)} - - - {R.toUpper(currency)} - -
-
- = -
-

Total assets

-
- - {numberToFiatAmount(totalValue)} - - - {R.toUpper(currency)} - -
-
-
- ) -} - -const WalletInfoChip = ({ wallet, currency }) => { - const classes = useStyles({ numberOfChips: CHIPS_PER_ROW }) - - const getLogo = cryptoCode => { - switch (cryptoCode) { - case 'BTC': - return - case 'ETH': - return - case 'LTC': - return - case 'ZEC': - return ( - - ) - case 'BCH': - return ( - - ) - case 'DASH': - return - default: - return - } - } - - return ( -
- -
- {getLogo(wallet.cryptoCode)} - - {wallet.isHedged ? 'Hedged' : 'Not hedged'} - -
-
- {wallet.name} value - - {numberToCryptoAmount(wallet.amount)} {wallet.cryptoCode} - - Hedged value - - {numberToFiatAmount(wallet.hedgedFiatValue)} {currency} - -
-
-
- ) -} - -const ATMWallet = () => { - const classes = useStyles({ numberOfChips: CHIPS_PER_ROW }) - const { userData } = useContext(AppContext) - - const { data, loading } = useQuery(GET_OPERATOR_BY_USERNAME, { - context: { clientName: 'pazuz' }, - variables: { username: userData?.username } - }) - - const operatorData = R.path(['operatorByUsername'], data) - - const wallets = [ - { - cryptoCode: 'BTC', - name: 'Bitcoin', - amount: operatorData?.cryptoBalances.xbt ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.xbt ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.xbt ?? 0, - isHedged: BigNumber(operatorData?.assets.values.hedgedCrypto.xbt ?? 0).gt( - 0 - ) - }, - { - cryptoCode: 'ETH', - name: 'Ethereum', - amount: operatorData?.cryptoBalances.eth ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.eth ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.eth ?? 0, - isHedged: BigNumber(operatorData?.assets.values.hedgedCrypto.eth ?? 0).gt( - 0 - ) - }, - { - cryptoCode: 'LTC', - name: 'Litecoin', - amount: operatorData?.cryptoBalances.ltc ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.ltc ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.ltc ?? 0, - isHedged: BigNumber(operatorData?.assets.values.hedgedCrypto.ltc ?? 0).gt( - 0 - ) - }, - { - cryptoCode: 'ZEC', - name: 'Zcash', - amount: operatorData?.cryptoBalances.zec ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.zec ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.zec ?? 0, - isHedged: BigNumber(operatorData?.assets.values.hedgedCrypto.zec ?? 0).gt( - 0 - ) - }, - { - cryptoCode: 'BCH', - name: 'Bitcoin Cash', - amount: operatorData?.cryptoBalances.bch ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.bch ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.bch ?? 0, - isHedged: BigNumber(operatorData?.assets.values.hedgedCrypto.bch ?? 0).gt( - 0 - ) - }, - { - cryptoCode: 'DASH', - name: 'Dash', - amount: operatorData?.cryptoBalances.dash ?? 0, - fiatValue: operatorData?.assets.values.cryptoBalancesInFiat.dash ?? 0, - hedgedFiatValue: operatorData?.assets.values.hedgedContracts.dash ?? 0, - isHedged: BigNumber( - operatorData?.assets.values.hedgedCrypto.dash ?? 0 - ).gt(0) - } - ] - - return ( - !loading && ( - <> - - -

ATM Wallets

-
- {R.map( - it => ( - - ), - wallets - )} -
- - ) - ) -} - -export default ATMWallet diff --git a/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.styles.js b/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.styles.js deleted file mode 100644 index 8715a627..00000000 --- a/new-lamassu-admin/src/pages/ATMWallet/ATMWallet.styles.js +++ /dev/null @@ -1,90 +0,0 @@ -import { offColor } from 'src/styling/variables' - -const styles = ({ numberOfChips }) => ({ - totalAssetWrapper: { - display: 'flex', - flexDirection: 'row' - }, - totalAssetFieldWrapper: { - display: 'flex', - flexDirection: 'column' - }, - fieldHeader: { - color: offColor, - marginBottom: 5 - }, - fieldValue: { - fontSize: 36 - }, - fieldCurrency: { - fontSize: 20, - alignSelf: 'flex-end', - margin: [[0, 0, 5, 5]] - }, - separator: { - fontSize: 32, - alignSelf: 'center', - margin: [[25, 20, 0, 20]] - }, - walletChipList: { - display: 'flex', - flexDirection: 'row', - flexWrap: 'wrap' - }, - walletChipWrapper: { - flexGrow: 0, - flexShrink: 0, - flexBasis: `16.66667%`, - '&:nth-child(6n+1)': { - '& > div': { - margin: [[0, 10, 0, 0]] - } - }, - '&:nth-child(6n)': { - '& > div': { - margin: [[0, 0, 0, 10]] - } - }, - margin: [[10, 0]] - }, - walletChip: { - height: 200, - margin: [[0, 10]] - }, - walletHeader: { - display: 'flex', - flexDirection: 'row', - justifyContent: 'space-between', - height: 50 - }, - logo: { - transform: `scale(0.4, 0.4)`, - height: 80, - maxWidth: 110, - margin: [[-14, 0, 0, -26]] - }, - zecLogo: { - margin: [[-15, 0, 0, -10]] - }, - bchLogo: { - margin: [[-12, 0, 0, -18]] - }, - hedgedText: { - color: offColor, - margin: [[13, 12, 0, 0]] - }, - walletValueWrapper: { - display: 'flex', - flexDirection: 'column', - margin: [[0, 0, 0, 15]] - }, - walletValue: { - fontSize: 18, - margin: [[0, 0, 10, 0]] - }, - walletChipTitle: { - marginTop: 50 - } -}) - -export default styles diff --git a/new-lamassu-admin/src/pages/Accounting/Accounting.js b/new-lamassu-admin/src/pages/Accounting/Accounting.js deleted file mode 100644 index dcc6b18d..00000000 --- a/new-lamassu-admin/src/pages/Accounting/Accounting.js +++ /dev/null @@ -1,203 +0,0 @@ -import { useQuery } from '@apollo/react-hooks' -import { makeStyles } from '@material-ui/core/styles' -import BigNumber from 'bignumber.js' -import gql from 'graphql-tag' -import * as R from 'ramda' -import React, { useContext } from 'react' - -import AppContext from 'src/AppContext' -import { HelpTooltip } from 'src/components/Tooltip' -import TitleSection from 'src/components/layout/TitleSection' -import DataTable from 'src/components/tables/DataTable' -import { H4, Info2, P } from 'src/components/typography' -import { numberToFiatAmount } from 'src/utils/number' -import { formatDate } from 'src/utils/timezones' - -import styles from './Accounting.styles' - -const useStyles = makeStyles(styles) - -const GET_OPERATOR_BY_USERNAME = gql` - query operatorByUsername($username: String) { - operatorByUsername(username: $username) { - id - entityId - name - fiatBalances - cryptoBalances - machines - joined - assets - preferredFiatCurrency - contactInfo { - name - email - } - fundings { - id - origin - destination - fiatAmount - fiatBalanceAfter - fiatCurrency - created - status - description - } - } - } -` - -const GET_DATA = gql` - query getData { - config - } -` - -const Assets = ({ balance, hedgingReserve, currency }) => { - const classes = useStyles() - - return ( -
-
-

Pazuz fiat balance

-
- - {numberToFiatAmount(balance)} - - - {R.toUpper(currency)} - -
-
- - -
-

Hedging reserve

-
- - {numberToFiatAmount(hedgingReserve)} - - - {R.toUpper(currency)} - -
-
- = -
-

Available balance

-
- - {numberToFiatAmount(balance - hedgingReserve)} - - - {R.toUpper(currency)} - -
-
-
- ) -} - -const Accounting = () => { - const classes = useStyles() - const { userData } = useContext(AppContext) - - const { data: opData, loading: operatorLoading } = useQuery( - GET_OPERATOR_BY_USERNAME, - { - context: { clientName: 'pazuz' }, - variables: { username: userData?.username } - } - ) - - const { data: configResponse, loading: configLoading } = useQuery(GET_DATA) - const timezone = R.path(['config', 'locale_timezone'], configResponse) - - const loading = operatorLoading || configLoading - - const operatorData = R.path(['operatorByUsername'], opData) - - const elements = [ - { - header: 'Operation', - width: 500, - size: 'sm', - textAlign: 'left', - view: it => { - return ( - - {it.description} - {!!it.extraInfo && ( - -

{it.extraInfo}

-
- )} -
- ) - } - }, - { - header: 'Amount', - width: 147, - size: 'sm', - textAlign: 'right', - view: it => - `${numberToFiatAmount(it.fiatAmount)} ${R.toUpper(it.fiatCurrency)}` - }, - { - header: 'Balance after operation', - width: 250, - size: 'sm', - textAlign: 'right', - view: it => - `${numberToFiatAmount(it.fiatBalanceAfter)} ${R.toUpper( - it.fiatCurrency - )}` - }, - { - header: 'Date', - width: 150, - size: 'sm', - textAlign: 'right', - view: it => formatDate(it.created, timezone, 'yyyy-MM-dd') - }, - { - header: 'Time', - width: 150, - size: 'sm', - textAlign: 'right', - view: it => formatDate(it.created, timezone, 'yyyy-MM-dd') - } - ] - - const hedgingReserve = BigNumber( - R.reduce( - (acc, value) => acc.plus(value), - BigNumber(0), - R.values(operatorData?.assets.values.hedgedContracts) ?? [] - ) ?? 0 - ).toNumber() - - return ( - !loading && ( - <> - - -

Fiat balance history

- - - ) - ) -} - -export default Accounting diff --git a/new-lamassu-admin/src/pages/Accounting/Accounting.styles.js b/new-lamassu-admin/src/pages/Accounting/Accounting.styles.js deleted file mode 100644 index e62a1c85..00000000 --- a/new-lamassu-admin/src/pages/Accounting/Accounting.styles.js +++ /dev/null @@ -1,39 +0,0 @@ -import { offColor } from 'src/styling/variables' - -const styles = () => ({ - totalAssetWrapper: { - display: 'flex', - flexDirection: 'row' - }, - totalAssetFieldWrapper: { - display: 'flex', - flexDirection: 'column' - }, - fieldHeader: { - color: offColor, - marginBottom: 5 - }, - fieldValue: { - fontSize: 36 - }, - fieldCurrency: { - fontSize: 20, - alignSelf: 'flex-end', - margin: [[0, 0, 5, 5]] - }, - separator: { - fontSize: 32, - alignSelf: 'center', - margin: [[25, 20, 0, 20]] - }, - tableTitle: { - marginTop: 35 - }, - operation: { - display: 'flex', - flexDirection: 'row', - alignItems: 'center' - } -}) - -export default styles diff --git a/new-lamassu-admin/src/pages/Assets/Assets.js b/new-lamassu-admin/src/pages/Assets/Assets.js deleted file mode 100644 index 6a2f8e8c..00000000 --- a/new-lamassu-admin/src/pages/Assets/Assets.js +++ /dev/null @@ -1,258 +0,0 @@ -import { useQuery } from '@apollo/react-hooks' -import Grid from '@material-ui/core/Grid' -import Table from '@material-ui/core/Table' -import TableBody from '@material-ui/core/TableBody' -import TableCell from '@material-ui/core/TableCell' -import TableContainer from '@material-ui/core/TableContainer' -import TableHead from '@material-ui/core/TableHead' -import TableRow from '@material-ui/core/TableRow' -import { makeStyles, withStyles } from '@material-ui/core/styles' -import gql from 'graphql-tag' -import * as R from 'ramda' -import React, { useContext } from 'react' - -import AppContext from 'src/AppContext' -import TitleSection from 'src/components/layout/TitleSection' -import { H4, Label2, P, Info2 } from 'src/components/typography' -import { numberToFiatAmount } from 'src/utils/number' - -import styles from './Assets.styles' - -const useStyles = makeStyles(styles) - -const GET_OPERATOR_BY_USERNAME = gql` - query operatorByUsername($username: String) { - operatorByUsername(username: $username) { - id - entityId - name - fiatBalances - cryptoBalances - machines - joined - assets - preferredFiatCurrency - contactInfo { - name - email - } - fundings { - id - origin - destination - fiatAmount - fiatBalanceAfter - fiatCurrency - created - status - description - } - } - } -` - -const cellStyling = { - borderBottom: '4px solid white', - padding: 0, - paddingLeft: 20, - paddingRight: 20 -} - -const Cell = withStyles({ - root: cellStyling -})(TableCell) - -const HeaderCell = withStyles({ - root: { - ...cellStyling, - backgroundColor: 'white' - } -})(TableCell) - -const AssetsAmountTable = ({ title, data = [], numToRender }) => { - const classes = useStyles() - - const totalAmount = R.compose(R.sum, R.map(R.path(['amount'])))(data) ?? 0 - const currency = data[0]?.currency ?? '' - const selectAmountPrefix = it => - it.direction === 'in' ? '+' : R.isNil(it.direction) ? '' : '-' - - return ( - <> - -

{title}

- - - - - -
- Asset -
-
- -
- Amount -
-
-
-
- - {data?.map((asset, idx) => { - if (!(idx < numToRender)) return <> - return ( - - -

{asset.display}

-
- -

{`${selectAmountPrefix(asset)} - ${numberToFiatAmount(Math.abs(asset.amount))} ${ - asset.currency - }`}

-
-
- ) - })} - - - {`Total ${R.toLower(title)}`} - - - {`${numberToFiatAmount( - totalAmount - )} ${currency}`} - - -
-
-
-
- - ) -} - -const Assets = () => { - const classes = useStyles() - const { userData } = useContext(AppContext) - - const { data, loading } = useQuery(GET_OPERATOR_BY_USERNAME, { - context: { clientName: 'pazuz' }, - variables: { username: userData?.username } - }) - - const operatorData = R.path(['operatorByUsername'], data) - - const balanceData = [ - { - id: 'fiatBalance', - display: 'Fiat balance', - amount: operatorData?.assets.total ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - class: 'Available balance' - }, - { - id: 'hedgingReserve', - display: 'Hedging reserve', - amount: - -R.sum(R.values(operatorData?.assets.values.hedgedContracts)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - class: 'Available balance', - direction: 'out' - } - ] - - const walletData = [ - { - id: 'hedgedWalletAssets', - display: 'Hedged wallet assets', - amount: R.sum(R.values(operatorData?.assets.values.hedgedContracts)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - class: 'Wallet assets', - direction: 'in' - }, - { - id: 'unhedgedWalletAssets', - display: 'Unhedged wallet assets', - amount: R.sum(R.values(operatorData?.assets.values.unhedgedFiat)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - class: 'Wallet assets', - direction: 'in' - } - ] - - const totalData = [ - { - id: 'fiatBalance', - display: 'Fiat balance', - amount: - operatorData?.fiatBalances[operatorData?.preferredFiatCurrency] ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? '') - }, - { - id: 'hedgingReserve', - display: 'Hedging reserve', - amount: - -R.sum(R.values(operatorData?.assets.values.hedgedContracts)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - direction: 'out' - }, - { - id: 'hedgedWalletAssets', - display: 'Market value of hedged wallet assets', - amount: R.sum(R.values(operatorData?.assets.values.hedgedContracts)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - direction: 'in' - }, - { - id: 'unhedgedWalletAssets', - display: 'Unhedged wallet assets', - amount: R.sum(R.values(operatorData?.assets.values.unhedgedFiat)) ?? 0, - currency: R.toUpper(operatorData?.preferredFiatCurrency ?? ''), - direction: 'in' - } - ] - - return ( - !loading && ( - <> - -
- - - -
- -
-
- -
-
-
- - -
- -
-
-
-
-
- - ) - ) -} - -export default Assets diff --git a/new-lamassu-admin/src/pages/Assets/Assets.styles.js b/new-lamassu-admin/src/pages/Assets/Assets.styles.js deleted file mode 100644 index eea2e084..00000000 --- a/new-lamassu-admin/src/pages/Assets/Assets.styles.js +++ /dev/null @@ -1,45 +0,0 @@ -import { - white, - offColor, - backgroundColor, - subheaderColor -} from 'src/styling/variables' - -const styles = () => ({ - card: { - wordWrap: 'break-word', - boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.08)', - borderRadius: 12, - padding: 24, - backgroundColor: white - }, - h4: { - marginTop: 0 - }, - label: { - margin: 0, - color: offColor - }, - asset: { - float: 'left' - }, - amount: { - float: 'right' - }, - row: { - backgroundColor: backgroundColor, - borderBottom: 'none' - }, - totalRow: { - backgroundColor: subheaderColor, - borderBottom: 'none' - }, - leftSide: { - margin: [[0, 10, 20, 0]] - }, - rightSide: { - margin: [[0, 0, 0, 10]] - } -}) - -export default styles diff --git a/new-lamassu-admin/src/pages/Authentication/Input2FAState.js b/new-lamassu-admin/src/pages/Authentication/Input2FAState.js index 31deaf63..e1778b35 100644 --- a/new-lamassu-admin/src/pages/Authentication/Input2FAState.js +++ b/new-lamassu-admin/src/pages/Authentication/Input2FAState.js @@ -1,6 +1,5 @@ import { useMutation, useLazyQuery } from '@apollo/react-hooks' import { makeStyles } from '@material-ui/core/styles' -import base64 from 'base-64' import { Form, Formik } from 'formik' import gql from 'graphql-tag' import React, { useContext, useState } from 'react' @@ -59,14 +58,7 @@ const Input2FAState = ({ state, dispatch }) => { const [input2FA, { error: mutationError }] = useMutation(INPUT_2FA, { onCompleted: ({ input2FA: success }) => { if (success) { - const options = { - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(state.clientField) - } - } - } - return getUserData(options) + return getUserData() } return setInvalidToken(true) } @@ -94,11 +86,6 @@ const Input2FAState = ({ state, dispatch }) => { password: state.passwordField, code: state.twoFAField, rememberMe: state.rememberMeField - }, - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(state.clientField) - } } } diff --git a/new-lamassu-admin/src/pages/Authentication/LoginState.js b/new-lamassu-admin/src/pages/Authentication/LoginState.js index 1716919b..63272ba2 100644 --- a/new-lamassu-admin/src/pages/Authentication/LoginState.js +++ b/new-lamassu-admin/src/pages/Authentication/LoginState.js @@ -1,7 +1,6 @@ import { useMutation, useLazyQuery } from '@apollo/react-hooks' import { makeStyles } from '@material-ui/core/styles' import { startAssertion } from '@simplewebauthn/browser' -import base64 from 'base-64' import { Field, Form, Formik } from 'formik' import gql from 'graphql-tag' import React, { useContext } from 'react' @@ -84,11 +83,6 @@ const LoginState = ({ state, dispatch, strategy }) => { variables: { username, password - }, - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(username) - } } } const { data: loginResponse } = await login(options) diff --git a/new-lamassu-admin/src/pages/Authentication/Register.js b/new-lamassu-admin/src/pages/Authentication/Register.js index f9e24e5f..dcc6e64c 100644 --- a/new-lamassu-admin/src/pages/Authentication/Register.js +++ b/new-lamassu-admin/src/pages/Authentication/Register.js @@ -90,16 +90,10 @@ const Register = () => { const classes = useStyles() const history = useHistory() const token = QueryParams().get('t') - const identifier = QueryParams().get('id') ?? null const [state, dispatch] = useReducer(reducer, initialState) const queryOptions = { - context: { - headers: { - 'Pazuz-Operator-Identifier': identifier - } - }, variables: { token: token }, onCompleted: ({ validateRegisterLink: info }) => { if (!info) { diff --git a/new-lamassu-admin/src/pages/Authentication/Setup2FAState.js b/new-lamassu-admin/src/pages/Authentication/Setup2FAState.js index 618ed89e..68233c99 100644 --- a/new-lamassu-admin/src/pages/Authentication/Setup2FAState.js +++ b/new-lamassu-admin/src/pages/Authentication/Setup2FAState.js @@ -1,6 +1,5 @@ import { useMutation, useQuery, useLazyQuery } from '@apollo/react-hooks' import { makeStyles } from '@material-ui/core/styles' -import base64 from 'base-64' import { Form, Formik } from 'formik' import gql from 'graphql-tag' import QRCode from 'qrcode.react' @@ -71,11 +70,6 @@ const Setup2FAState = ({ state, dispatch }) => { const queryOptions = { variables: { username: state.clientField, password: state.passwordField }, - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(state.clientField) - } - }, onCompleted: ({ get2FASecret }) => { setSecret(get2FASecret.secret) setOtpauth(get2FASecret.otpauth) @@ -88,11 +82,6 @@ const Setup2FAState = ({ state, dispatch }) => { password: state.passwordField, rememberMe: state.rememberMeField, codeConfirmation: twoFAConfirmation - }, - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(state.clientField) - } } } @@ -107,14 +96,7 @@ const Setup2FAState = ({ state, dispatch }) => { const [setup2FA, { error: mutationError }] = useMutation(SETUP_2FA, { onCompleted: ({ setup2FA: success }) => { - const options = { - context: { - headers: { - 'Pazuz-Operator-Identifier': base64.encode(state.clientField) - } - } - } - success ? getUserData(options) : setInvalidToken(true) + success ? getUserData() : setInvalidToken(true) } }) diff --git a/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.js b/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.js index b6c21dc3..e4f5ea73 100644 --- a/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.js +++ b/new-lamassu-admin/src/pages/UserManagement/modals/CreateUserModal.js @@ -1,6 +1,5 @@ import { useMutation } from '@apollo/react-hooks' import { makeStyles } from '@material-ui/core/styles' -import base64 from 'base-64' import classnames from 'classnames' import { Field, Form, Formik } from 'formik' import gql from 'graphql-tag' @@ -75,12 +74,7 @@ const CreateUserModal = ({ state, dispatch }) => { const [createUser, { error }] = useMutation(CREATE_USER, { onCompleted: ({ createRegisterToken: token }) => { - const queryParams = - // Pazuz-created register tokens add a field to identify the creator - process.env.REACT_APP_BUILD_TARGET === 'LAMASSU' - ? `t=${token.token}` - : `t=${token.token}&id=${base64.encode(usernameField)}` - setCreateUserURL(urlResolver(`/register?${queryParams}`)) + setCreateUserURL(urlResolver(`/register?t${token.token}`)) } }) diff --git a/new-lamassu-admin/src/pages/Wizard/Wizard.js b/new-lamassu-admin/src/pages/Wizard/Wizard.js index fe68d1bf..b9ee1bb6 100644 --- a/new-lamassu-admin/src/pages/Wizard/Wizard.js +++ b/new-lamassu-admin/src/pages/Wizard/Wizard.js @@ -2,7 +2,6 @@ import { useQuery } from '@apollo/react-hooks' import { makeStyles, Dialog, DialogContent } from '@material-ui/core' import classnames from 'classnames' import gql from 'graphql-tag' -import * as R from 'ramda' import React, { useState, useContext } from 'react' import { useHistory } from 'react-router-dom' @@ -53,18 +52,6 @@ const Wizard = ({ fromAuthRegister }) => { const [footerExp, setFooterExp] = useState(false) - const getSteps = STEPS => { - const buildTarget = process.env.REACT_APP_BUILD_TARGET - if (buildTarget === 'PAZUZ') { - return R.filter(step => step.id !== 'wallet' && step.id !== 'twilio')( - STEPS - ) - } - return STEPS - } - - const steps = getSteps(STEPS) - if (loading) { return <> } @@ -91,7 +78,7 @@ const Wizard = ({ fromAuthRegister }) => { } const doContinue = () => { - if (step >= steps.length - 1) { + if (step >= STEPS.length - 1) { setOpen(false) history.push('/') } @@ -102,7 +89,7 @@ const Wizard = ({ fromAuthRegister }) => { setStep(nextStep) } - const current = steps[step] + const current = STEPS[step] return ( @@ -112,7 +99,7 @@ const Wizard = ({ fromAuthRegister }) => { {!isWelcome && (