Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Allow sending and retrieval of additionalContext within authentication flow #937

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/marko-web-identity-x/browser/authenticate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ export default {
isProfileComplete: this.isProfileComplete,
requiresCustomFieldAnswers: this.requiresCustomFieldAnswers,
actionSource: data.loginSource,
...(
data.additionalEventData
&& data.additionalEventData.newsletterSignupType
&& { newsletterSignupType: data.additionalEventData.newsletterSignupType }
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, this will be present under additionalEventData.newsletterSignupType below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solocommand This is how P1 Events expects it to be sent in order to send it accordingly via this: https://github.com/parameter1/base-cms/blob/master/packages/marko-web-p1-events/browser/index.js#L69

additionalEventData: {
...(this.additionalEventData || {}),
...(data.additionalEventData || {}),
Expand Down
4 changes: 3 additions & 1 deletion packages/marko-web-identity-x/routes/authenticate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const gql = require('graphql-tag');
const { getAsObject } = require('@parameter1/base-cms-object-path');
const { asyncRoute } = require('@parameter1/base-cms-utils');
const tokenCookie = require('../utils/token-cookie');
const contextCookie = require('../utils/context-cookie');
Expand All @@ -16,6 +17,7 @@ const loginAppUser = gql`
...ActiveUserFragment
}
loginSource
additionalEventData
}
}

Expand Down Expand Up @@ -51,7 +53,7 @@ module.exports = asyncRoute(async (req, res) => {
applicationId: identityX.config.getAppId(),
user,
loginSource,
additionalEventData,
additionalEventData: { ...additionalEventData, ...getAsObject(data, 'loginAppUser.additionalEventData') },
entity,
});
});
1 change: 1 addition & 0 deletions packages/marko-web-identity-x/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ class IdentityX {
appContextId: this.config.get('appContextId'),
source,
redirectTo,
additionalEventData,
},
},
});
Expand Down
Loading