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

Commit

Permalink
Add extra protection to source
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner committed Dec 13, 2019
1 parent 8805a35 commit b1c5dbf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion aws/handlers/Handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Handler {
const userId = profile.user_id;
const shortUserId = helpers.truncateUserId(userId);
this._logger.prefix = shortUserId;
const source = event.directive.payload.source || 'user';
const source = this.retrieveSource(event);
const context = {
userId: userId,
shortUserId: shortUserId,
Expand Down Expand Up @@ -59,6 +59,13 @@ class Handler {
return new MockProfileGateway();
}

retrieveSource(event) {
if (event.directive.payload && event.directive.payload.source) {
return event.directive.payload.source;
}
return 'user';
}

async retrieveProfile(event) {
if (event.directive.endpoint && event.directive.endpoint.userId) {
this._logger.debug('UserId found; skipping profile data...');
Expand Down

0 comments on commit b1c5dbf

Please sign in to comment.