fix: Fix mock-api login functionality

Squashed commit of the following:

commit 9022427d59290dfd2b08c4a076d6b0690d44d926
Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se>
Date:   Mon Sep 13 13:25:05 2021 +0200

    Update mock-apis
This commit is contained in:
Daniel Appelgren
2021-09-14 13:26:04 +02:00
parent 2a37566c38
commit 52cd7ad6f4
5 changed files with 45 additions and 24 deletions

View File

@@ -12,15 +12,16 @@ server.use(
'*sort=utforandeVerksamhet*': '$1sort=utforandeVerksamhet[0]$2',
'*sort=tjanst*': '$1sort=tjanst[0]$2',
'/users/invite*': '/invites$1',
'/users*': '/employees$1',
'/employees*search=*': '/employees$1fullName_like=$2',
'/employees*onlyEmployeesWithoutAuthorization=*': '/employees$1roles.length_lte=1',
'/employees*': '/employees$1',
'/services*': '/tjanster$1',
'/participants': '/participants?_embed=employees',
'/participant/:id': '/participants/:id?_embed=employees',
'/auth/userinfo': '/currentUser',
'/auth/organizations': '/currentUser',
'/auth/userinfo': '/userinfo',
'/auth/organizations': '/organizations',
'/users/currentUser': '/currentUser',
'/users*': '/employees$1',
'/avrop/tjanster*': '/avropTjanster$1',
'/avrop/handledare*': '/handledare$1',
'/avrop/utforandeverksamheter*': '/utforandeVerksamheter$1',
@@ -80,25 +81,10 @@ router.render = (req, res) => {
}
let data = res.locals.data;
const employeeRegex = /(?:\/users\/)(.*)/;
const isEmployeePath = employeeRegex.exec(pathname);
const deltagareRegex = /(?:\/deltagare\/)(?:\d*\/)(contact|driverlicense|educationlevels\/highest|educations|translator|work\/disabilities|work\/languages|work\/experiences)/g;
const isDeltagarePath = deltagareRegex.exec(pathname);
const avropRegex = /(?:\/avrop\/(?:tjanster|utforandeverksamheter|kommuner|\d))|(?:\/deltagare\/\d\/(avrop))/g;
const isAvropPath = avropRegex.exec(pathname);
const authRegex = /(?:\/auth\/)(userinfo|organizations)/g;
const isAuthPath = authRegex.exec(pathname);
if (isAuthPath) {
const authSubPath = isAuthPath[1];
if (authSubPath === 'organizations') {
data = res.locals.data[authSubPath].map(organization => ({
name: organization.name,
organizationnumber: organization.organizationNumber,
}));
}
}
if (isDeltagarePath) {
const deltagareSubPath = getDeltagareSubPath(isDeltagarePath[1]);