mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +00:00
fixing mfauth
This commit is contained in:
parent
cda2f377d7
commit
545d9c7993
@ -130,8 +130,12 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
if (!addingMfa) {
|
if (!addingMfa) {
|
||||||
setAddingMfa(true);
|
setAddingMfa(true);
|
||||||
try {
|
try {
|
||||||
await actions.enableMFA();
|
if (checked) {
|
||||||
mfaOpen();
|
await actions.enableMFA();
|
||||||
|
mfaOpen();
|
||||||
|
} else {
|
||||||
|
await actions.disableMFA();
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
showError()
|
showError()
|
||||||
@ -143,9 +147,13 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
const confirmMfa = async () => {
|
const confirmMfa = async () => {
|
||||||
if (!savingMfa) {
|
if (!savingMfa) {
|
||||||
setSavingMfa(true);
|
setSavingMfa(true);
|
||||||
|
try {
|
||||||
mfaClose();
|
await actions.confirmMFA();
|
||||||
|
mfaClose();
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
showError();
|
||||||
|
}
|
||||||
setSavingMfa(false);
|
setSavingMfa(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,6 +359,7 @@ export function Settings({ showLogout }: { showLogout: boolean }) {
|
|||||||
</div>
|
</div>
|
||||||
<Text className={classes.entryLabel}>{state.strings.mfaTitle}</Text>
|
<Text className={classes.entryLabel}>{state.strings.mfaTitle}</Text>
|
||||||
<Switch className={classes.entryControl}
|
<Switch className={classes.entryControl}
|
||||||
|
checked={state.config.mfaEnabled}
|
||||||
onChange={(ev) => setMfa(ev.currentTarget.checked)}
|
onChange={(ev) => setMfa(ev.currentTarget.checked)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,9 +159,9 @@ export function useSettings() {
|
|||||||
const { settings } = getSession()
|
const { settings } = getSession()
|
||||||
await settings.disableMFA()
|
await settings.disableMFA()
|
||||||
},
|
},
|
||||||
confirmMFA: async (code: string) => {
|
confirmMFA: async () => {
|
||||||
const { settings } = getSession()
|
const { settings } = getSession()
|
||||||
await settings.confirmMFA(code)
|
await settings.confirmMFA(state.code)
|
||||||
},
|
},
|
||||||
setCode: (code: string) => {
|
setCode: (code: string) => {
|
||||||
updateState({ code });
|
updateState({ code });
|
||||||
|
@ -160,7 +160,7 @@ export type ConfigEntity = {
|
|||||||
sealable: boolean,
|
sealable: boolean,
|
||||||
seal: SealEntity,
|
seal: SealEntity,
|
||||||
enableIce: boolean,
|
enableIce: boolean,
|
||||||
multiFactorAuth: boolean,
|
mfaEnabled: boolean,
|
||||||
webPushKey: string,
|
webPushKey: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ export const defaultConfigEntity = {
|
|||||||
seal: { passwordSalt: '', privateKeyIv: '', privateKeyEncrypted: '', publicKey: '' },
|
seal: { passwordSalt: '', privateKeyIv: '', privateKeyEncrypted: '', publicKey: '' },
|
||||||
sealable: false,
|
sealable: false,
|
||||||
enableIce: false,
|
enableIce: false,
|
||||||
multiFactorAuth: false,
|
mfaEnabled: false,
|
||||||
webPushKey: '',
|
webPushKey: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||||
|
|
||||||
export async function removeAccountMFAuth(node: string, secure: boolean, token: string) {
|
export async function removeAccountMFAuth(node: string, secure: boolean, token: string) {
|
||||||
const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth=${token}`;
|
const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth?agent=${token}`;
|
||||||
const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' })
|
const { status } = await fetchWithTimeout(endpoint, { method: 'DELETE' })
|
||||||
checkResponse(status);
|
checkResponse(status);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||||
|
|
||||||
export async function setAccountMFAuth(node: string, secure: boolean, token: string, code: string) {
|
export async function setAccountMFAuth(node: string, secure: boolean, token: string, code: string) {
|
||||||
const endpoint = `http${secure ? 's' : ''}://${node}/account/agent=${token}&code=${code}`;
|
const endpoint = `http${secure ? 's' : ''}://${node}/account/mfauth?agent=${token}&code=${code}`;
|
||||||
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT' })
|
const { status } = await fetchWithTimeout(endpoint, { method: 'PUT' })
|
||||||
checkResponse(status);
|
checkResponse(status);
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,11 @@ export class SettingsModule implements Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getConfig() {
|
public getConfig() {
|
||||||
const { storageUsed, storageAvailable, forwardingAddress, searchable, allowUnsealed, pushEnabled, sealable, seal, enableIce, multiFactorAuth, webPushKey } = this.config;
|
const { storageUsed, storageAvailable, forwardingAddress, searchable, allowUnsealed, pushEnabled, sealable, seal, enableIce, mfaEnabled, webPushKey } = this.config;
|
||||||
const { passwordSalt, privateKeyIv, privateKeyEncrypted, publicKey } = seal || {};
|
const { passwordSalt, privateKeyIv, privateKeyEncrypted, publicKey } = seal || {};
|
||||||
const sealSet = Boolean(passwordSalt && privateKeyIv && privateKeyEncrypted && publicKey);
|
const sealSet = Boolean(passwordSalt && privateKeyIv && privateKeyEncrypted && publicKey);
|
||||||
const sealUnlocked = Boolean(sealSet && this.sealKey?.privateKey && this.sealKey?.publicKey == publicKey)
|
const sealUnlocked = Boolean(sealSet && this.sealKey?.privateKey && this.sealKey?.publicKey == publicKey)
|
||||||
return { storageUsed, storageAvailable, forwardingAddress, searchable, allowUnsealed, pushEnabled, sealable, sealSet, sealUnlocked, enableIce, multiFactorAuth, webPushKey };
|
return { storageUsed, storageAvailable, forwardingAddress, searchable, allowUnsealed, pushEnabled, sealable, sealSet, sealUnlocked, enableIce, mfaEnabled, webPushKey };
|
||||||
}
|
}
|
||||||
|
|
||||||
public addConfigListener(ev: (config: Config) => void): void {
|
public addConfigListener(ev: (config: Config) => void): void {
|
||||||
|
@ -155,7 +155,7 @@ export type Config = {
|
|||||||
sealSet: boolean,
|
sealSet: boolean,
|
||||||
sealUnlocked: boolean,
|
sealUnlocked: boolean,
|
||||||
enableIce: boolean,
|
enableIce: boolean,
|
||||||
multiFactorAuth: boolean,
|
mfaEnabled: boolean,
|
||||||
webPushKey: string,
|
webPushKey: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user