mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +00:00
adding otp disable confirmation
This commit is contained in:
parent
07b9d06893
commit
ed369424cd
@ -34,7 +34,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
padding-bottom: 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.secretImage {
|
.secretImage {
|
||||||
@ -47,6 +46,10 @@
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.authMessage {
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.copyIcon {
|
.copyIcon {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
const [sealDelete, setSealDelete] = useState(false)
|
const [sealDelete, setSealDelete] = useState(false)
|
||||||
const [sealReset, setSealReset] = useState(false)
|
const [sealReset, setSealReset] = useState(false)
|
||||||
const [sealConfig, setSealConfig] = useState(false)
|
const [sealConfig, setSealConfig] = useState(false)
|
||||||
|
const [authMessage, setAuthMessage] = useState('');
|
||||||
|
|
||||||
const logout = () =>
|
const logout = () =>
|
||||||
modals.openConfirmModal({
|
modals.openConfirmModal({
|
||||||
@ -91,6 +92,20 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
onConfirm: actions.logout,
|
onConfirm: actions.logout,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const clearMfa = () => {
|
||||||
|
modals.openConfirmModal({
|
||||||
|
title: state.strings.confirmDisable,
|
||||||
|
withCloseButton: true,
|
||||||
|
overlayProps: {
|
||||||
|
backgroundOpacity: 0.55,
|
||||||
|
blur: 3,
|
||||||
|
},
|
||||||
|
children: <Text>{state.strings.disablePrompt}</Text>,
|
||||||
|
labels: { confirm: state.strings.disable, cancel: state.strings.cancel },
|
||||||
|
onConfirm: actions.disableMFA
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const setRegistry = async (checked: boolean) => {
|
const setRegistry = async (checked: boolean) => {
|
||||||
if (!savingRegistry) {
|
if (!savingRegistry) {
|
||||||
setSavingRegistry(true)
|
setSavingRegistry(true)
|
||||||
@ -144,10 +159,12 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
setAddingMfa(true);
|
setAddingMfa(true);
|
||||||
try {
|
try {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
actions.setCode('');
|
||||||
|
setAuthMessage('');
|
||||||
await actions.enableMFA();
|
await actions.enableMFA();
|
||||||
mfaOpen();
|
mfaOpen();
|
||||||
} else {
|
} else {
|
||||||
await actions.disableMFA();
|
clearMfa();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
@ -164,8 +181,13 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
await actions.confirmMFA();
|
await actions.confirmMFA();
|
||||||
mfaClose();
|
mfaClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
if (err.message === '401') {
|
||||||
showError();
|
setAuthMessage(state.strings.mfaError);
|
||||||
|
} else if (err.message === '429') {
|
||||||
|
setAuthMessage(state.strings.mfaDisabled);
|
||||||
|
} else {
|
||||||
|
setAuthMessage(`${state.strings.error}: ${state.strings.tryAgain}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setSavingMfa(false);
|
setSavingMfa(false);
|
||||||
}
|
}
|
||||||
@ -747,6 +769,7 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
className={classes.mfaPin}
|
className={classes.mfaPin}
|
||||||
onChange={(event) => actions.setCode(event)}
|
onChange={(event) => actions.setCode(event)}
|
||||||
/>
|
/>
|
||||||
|
<Text className={classes.authMessage}>{ authMessage }</Text>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.control}>
|
<div className={classes.control}>
|
||||||
<Button variant="default" onClick={mfaClose}>
|
<Button variant="default" onClick={mfaClose}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user