Skip to content

Create Jobs in TaaS using user token instead of M2M #624

Closed
@maxceem

Description

@maxceem

We have one issue with the current way of creating Jobs in TaaS API from Projects API Kafka Consumer https://github.com/topcoder-platform/tc-project-service/blob/develop/src/events/projects/index.js#L24

At the moment when the user creates a project using Connect Intake Form, the Jobs are created by Projects API Kafka Consumer using M2M token.

But there is a restriction in TaaS API: users can only edit jobs they created. As a result, when a regular user creates jobs using Connect Intake form, such jobs are created using M2M token, and then a user who created them, cannot edit them, because in TaaS API such user is not set to createdBy .

To fix this issue we have to create Jobs in Projects API using user token from the request instead of the M2M token. But there is a tricky moment, we don't pass user token inside Kafka Events.

So I think the best way to fix it is to move the logic of creating Jobs on projects creation from Kafka Event to the internal Event Emitter and handle job creations here https://github.com/topcoder-platform/tc-project-service/blob/develop/src/events/busApi.js#L57-L64. At this point, we have access to the request objects so we can use user token, and this logic would be still quite decoupled from the main project creation logic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions