Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Endpoint: Add a Person to Project #47

Open
3 of 4 tasks
syedfkabir opened this issue Oct 27, 2022 · 0 comments
Open
3 of 4 tasks

New Endpoint: Add a Person to Project #47

syedfkabir opened this issue Oct 27, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@syedfkabir
Copy link
Contributor

syedfkabir commented Oct 27, 2022

Endpoint

  • Endpoint /project/123/people
  • Method: POST

Body:

  1. Should be json-schema validated

  2. Should have 3 properties: href and role and name

  3. Role should be one of "member", "manager", "owner".

  4. 'href' should be in the format mailto:[email protected]

Form

I recommend you make a 'HAL Form' on the /project/123 endpoint with those 2 fields so it's easy test.

Once you get to this point, I think this is already a good place for the first PR even if the endpoint doesn't do anything yet.

Step 2: Figuring out the principal

With the 'href' in mind, you can call the /user/byhref/{href} endpoint on a12nserver using the ketting client in this repository. Replace {href} with the one you got from the body.

There's 2 possible outcomes:

  1. You got principal information (great)
  2. You got a 404.

If you got the 404, create a new principal on a12nserver by doing a POST request on /users. After this you should get a new principal uri.

This means at this point you have a principal uri for the resource, whether a new principal created, or not.

This is another good checkpoint for a PR.

Step 3: Finding the tt-api 'person'

Now you have a principal URI, see if a user exists in your people table with that same uri. If it doesn't exists, create the new record.

This is another PR

Step 4: Add the privilege entry

You can do this with the existing addUserPrivilege function in a12n.ts

Done!

@syedfkabir syedfkabir self-assigned this Oct 27, 2022
@syedfkabir syedfkabir added the enhancement New feature or request label Oct 27, 2022
@syedfkabir syedfkabir moved this to In Progress in Time Tracker Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

1 participant