Skip to content

Commit

Permalink
fix: check signed for invitation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Nicolae committed Mar 6, 2024
1 parent 1c03d19 commit 99309c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "eionet2-user-management",
"version": "1.2.6",
"version": "1.2.7",
"description": "",
"author": "",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tabs/package.json
@@ -1,6 +1,6 @@
{
"name": "@eeacms/eionet2-user-management",
"version": "1.2.6",
"version": "1.2.7",
"license": "MIT",
"description": "Teams app for managing Eionet users.",
"dependencies": {
Expand Down
26 changes: 10 additions & 16 deletions tabs/src/data/provider.js
Expand Up @@ -113,17 +113,18 @@ export async function inviteUser(user, mappings) {
} else {
userId = user.ADProfile.id;
try {
//check MFA status only for existing
user.LastInvitationDate = new Date();
const mfaResponse = await checkMFAStatus(user.ADProfile.displayName);
user.SignedIn = mfaResponse?.value?.length > 0 && mfaResponse.value[0].isMfaRegistered;

await saveADUser(userId, user);
} catch (err) {
return wrapError(err, messages.UserEdit.Errors.ADUser);
}
sendMail = true;
}

user.LastInvitationDate = new Date();
const mfaResponse = await checkMFAStatus(buildUserDisplaName(user));
user.SignedIn = mfaResponse?.value?.length > 0 && mfaResponse.value[0].isMfaRegistered;

if (userId) {
try {
//If NFP save to NFPs groups and Main EIONET group
Expand All @@ -141,15 +142,6 @@ export async function inviteUser(user, mappings) {
} catch (err) {
return wrapError(err, messages.UserInvite.Errors.JoiningTeam);
}

if (user.SignedIn) {
try {
await addTag(config.MainEionetGroupId, constants.NFP_TAG, userId);
await addTag(config.MainEionetGroupId, getCountryName(user.Country), userId);
} catch (err) {
return wrapError(err, messages.UserInvite.Errors.TagsCreation);
}
}
}

const userMappings = mappings.filter(
Expand All @@ -164,9 +156,6 @@ export async function inviteUser(user, mappings) {
try {
for (const groupId of userGroupIds.filter((id) => !existingGroups?.includes(id))) {
await postUserGroup(groupId, userId);

const groupMapping = userMappings.filter((m) => m.O365GroupId === groupId);
groupMapping[0]?.Tag && addTag(groupId, getCountryName(user.Country), userId);
}
} catch (err) {
return wrapError(err, messages.UserInvite.Errors.JoiningTeam);
Expand All @@ -175,9 +164,14 @@ export async function inviteUser(user, mappings) {
if (user.SignedIn) {
//apply membership tags
try {
if (user.NFP) {
await addTag(config.MainEionetGroupId, constants.NFP_TAG, userId);
await addTag(config.MainEionetGroupId, getCountryName(user.Country), userId);
}
const tags = [...new Set(userMappings.filter((m) => m.Tag))];
for (const m of tags) {
addTag(m.O365GroupId, m.Tag, userId);
addTag(m.O365GroupId, getCountryName(user.Country), userId);
}
} catch (err) {
return wrapError(err, messages.UserInvite.Errors.TagsCreation);
Expand Down

0 comments on commit 99309c4

Please sign in to comment.