update mock handlers

This commit is contained in:
Jacob Overgaard
2024-05-17 11:28:20 +02:00
parent c198eebfab
commit 0c7aa8d7e4
3 changed files with 23 additions and 29 deletions

View File

@@ -128,8 +128,4 @@ export const mfaLoginProviders: Array<UserTwoFactorProviderModel> = [
isEnabledOnUser: false,
providerName: 'sms',
},
{
isEnabledOnUser: true,
providerName: 'Email',
},
];

View File

@@ -76,6 +76,15 @@ const privateManifests: PackageManifestResponse = [
label: 'Setup SMS Verification',
},
},
{
type: 'mfaLoginProvider',
alias: 'My.MfaLoginProvider.Custom.Email',
name: 'My Custom Email MFA Provider',
forProviderName: 'email',
meta: {
label: 'Setup Email Verification',
},
},
],
},
{
@@ -92,20 +101,6 @@ const privateManifests: PackageManifestResponse = [
},
],
},
{
name: 'My MFA Package',
extensions: [
{
type: 'mfaLoginProvider',
alias: 'My.MfaLoginProvider.Custom',
name: 'My Custom MFA Provider',
forProviderName: 'sms',
meta: {
label: 'Setup SMS Verification',
},
},
],
},
];
const publicManifests: PackageManifestResponse = [

View File

@@ -1,7 +1,7 @@
const { rest } = window.MockServiceWorker;
import { umbUserMockDb } from '../../data/user/user.db.js';
import { UMB_SLUG } from './slug.js';
import type { LinkedLoginsRequestModel } from '@umbraco-cms/backoffice/external/backend-api';
import type { LinkedLoginsRequestModel, UserData } from '@umbraco-cms/backoffice/external/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
export const handlers = [
@@ -9,19 +9,22 @@ export const handlers = [
const loggedInUser = umbUserMockDb.getCurrentUser();
return res(ctx.status(200), ctx.json(loggedInUser));
}),
rest.get<LinkedLoginsRequestModel>(umbracoPath(`${UMB_SLUG}/current/logins`), (_req, res, ctx) => {
return res(
ctx.status(200),
ctx.json<LinkedLoginsRequestModel>({
linkedLogins: [
rest.get<UserData['responses']['GetUserCurrentLoginProviders']>(
umbracoPath(`${UMB_SLUG}/current/login-providers`),
(_req, res, ctx) => {
return res(
ctx.status(200),
ctx.json<UserData['responses']['GetUserCurrentLoginProviders']>([
{
hasManualLinkingEnabled: true,
isLinkedOnUser: true,
providerKey: 'google',
providerName: 'Umbraco.Google',
providerSchemeName: 'Umbraco.Google',
},
],
}),
);
}),
]),
);
},
),
rest.get(umbracoPath(`${UMB_SLUG}/current/2fa`), (_req, res, ctx) => {
const mfaLoginProviders = umbUserMockDb.getMfaLoginProviders();
return res(ctx.status(200), ctx.json(mfaLoginProviders));