feat(core): Add MFA (#4767)

https://linear.app/n8n/issue/ADO-947/sync-branch-with-master-and-fix-fe-e2e-tets

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Ricardo Espinoza
2023-08-23 22:59:16 -04:00
committed by GitHub
parent a01c3fbc19
commit 2b7ba6fdf1
61 changed files with 2301 additions and 105 deletions

View File

@@ -0,0 +1,23 @@
import type { IRestApiContext } from '@/Interface';
import { makeRestApiRequest } from '@/utils/apiUtils';
export async function getMfaQR(
context: IRestApiContext,
): Promise<{ qrCode: string; secret: string; recoveryCodes: string[] }> {
return makeRestApiRequest(context, 'GET', '/mfa/qr');
}
export async function enableMfa(context: IRestApiContext, data: { token: string }): Promise<void> {
return makeRestApiRequest(context, 'POST', '/mfa/enable', data);
}
export async function verifyMfaToken(
context: IRestApiContext,
data: { token: string },
): Promise<void> {
return makeRestApiRequest(context, 'POST', '/mfa/verify', data);
}
export async function disableMfa(context: IRestApiContext): Promise<void> {
return makeRestApiRequest(context, 'DELETE', '/mfa/disable');
}

View File

@@ -16,7 +16,7 @@ export async function loginCurrentUser(
export async function login(
context: IRestApiContext,
params: { email: string; password: string },
params: { email: string; password: string; mfaToken?: string; mfaRecoveryToken?: string },
): Promise<CurrentUserResponse> {
return makeRestApiRequest(context, 'POST', '/login', params);
}
@@ -74,7 +74,7 @@ export async function validatePasswordToken(
export async function changePassword(
context: IRestApiContext,
params: { token: string; password: string },
params: { token: string; password: string; mfaToken?: string },
): Promise<void> {
await makeRestApiRequest(context, 'POST', '/change-password', params);
}