feat: omit pazuz-related headers when build target is lamassu

fix: rename headers to get up to standard
feat: pazuz user registration links now contain schema identification param
This commit is contained in:
Sérgio Salgado 2021-09-23 15:41:33 +01:00
parent 6f285d30c5
commit eb18440320
5 changed files with 92 additions and 35 deletions

View file

@ -2,6 +2,7 @@ import { useMutation, useLazyQuery } from '@apollo/react-hooks'
import { makeStyles } from '@material-ui/core/styles'
import base64 from 'base-64'
import gql from 'graphql-tag'
import * as R from 'ramda'
import React, { useContext, useState } from 'react'
import { useHistory } from 'react-router-dom'
@ -58,13 +59,18 @@ const Input2FAState = ({ state, dispatch }) => {
const [input2FA, { error: mutationError }] = useMutation(INPUT_2FA, {
onCompleted: ({ input2FA: success }) => {
if (success) {
return getUserData({
const options = {
context: {
headers: {
pazuz_operatoridentifier: base64.encode(state.clientField)
'Pazuz-Operator-Identifier': base64.encode(state.clientField)
}
}
})
}
return getUserData(
process.env.REACT_APP_BUILD_TARGET === 'LAMASSU'
? R.omit(['context'], options)
: options
)
}
return setInvalidToken(true)
}
@ -86,7 +92,7 @@ const Input2FAState = ({ state, dispatch }) => {
return
}
input2FA({
const options = {
variables: {
username: state.clientField,
password: state.passwordField,
@ -95,10 +101,16 @@ const Input2FAState = ({ state, dispatch }) => {
},
context: {
headers: {
pazuz_operatoridentifier: base64.encode(state.clientField)
'Pazuz-Operator-Identifier': base64.encode(state.clientField)
}
}
})
}
input2FA(
process.env.REACT_APP_BUILD_TARGET === 'LAMASSU'
? R.omit(['context'], options)
: options
)
}
const getErrorMsg = () => {