Skip to content
Snippets Groups Projects
Commit 49b9f1e9 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'develop' of https://gitlab.coko.foundation/xpub/xpub-faraday into develop

parents df17c385 0258bd63
No related branches found
No related tags found
1 merge request!10Sprint #12
# Invite Component # Invite Component
## Configuration ### Invite a User to a Collection [POST]
In order to use this component, the following configuration needs to be added to a PubSweet application, like so: This endpoint allows creates a new User, linking it to a Collection through a Team.
```json #### Invite User Request
{
'invite-reset-password': {
url: 'http://localhost:3000/invite',
},
roles: {
global: ['admin', 'editorInChief', 'author'],
collection: ['handlingEditor', 'reviewer'],
inviteRights: {
admin: ['admin', 'editorInChief', 'author'],
editorInChief: ['handlingEditor'],
handlingEditor: ['reviewer'],
},
},
```
## Usage
Here's the list of endpoints that'll help you invite new users in your Pubsweet app.
### Upload a file [POST] `POST /api/collections/:collectionId/invitations`
This endpoint allows you to create a new user in your app and then send him a confirmation email.
#### Invite request
`POST /api/users/invite/{collectionId}`
| URI Parameter | Requiered | Requirements | Description | | URI Parameter | Requiered | Requirements | Description |
| ------------- | --------- | ------------ | ------------------ | | ------------- | --------- | ------------ | ------------------ |
| collectionId | No | String | The ID of the collection | | collectionId | No | String | The ID of the collection |
#### Invite request body #### Invite User Request Body
```json ```json
{ {
"email": "new_user@domain.com" /* required */, "email": "email@example.com",
"role": "editorInChief" /* required */, "role": "handlingEditor", [acceptedValues: handlingEditor, reviewer]
"firstName": "Marc",
"lastName": "Twain",
"title": "Prof",
"affiliation": "MIT"
} }
``` ```
#### Invite user response #### Invite User Response
```json ```javascript
HTTP/1.1 200 HTTP/1.1 200 OK
{ {
"id": "37463722-c4ca-4e3c-acec-779df8c11ad2", "id": "7b2431af-210c-49f9-a69a-e19271066ebd",
"username": "9a42b55f", "role": "handlingEditor",
"email": "new_user@domain.com", "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
"roles": ["editorInChief"], "hasAnswer": false,
"passwordResetToken": "123", "invitedOn": 1525428890167,
"isConfirmed": false, "isAccepted": false,
"firstName": "Marc", "respondedOn": null
"lastName": "Twain", }
"affiliation": "MIT",
"title": "Prof",
"admin": false,
"type": "user",
"rev": "1-12ebbb6686614791bb08ead305cde4f8"
}
``` ```
--- ---
### Retrieve invited user details [GET] ### Get Invitations [GET]
This endpoint allows you to retrieve an invited users' details so that you can display them in the confirmation form. This endpoint allows you to get a list of invitations based on role.
#### User details request #### Get Invitations Request
`GET /api/users/invite?email=new_user@domain.com&token=123` `GET /api/collections/:collectionId/invitations/:invitationId?role=:role`
| Query Parameter | Requiered | Requirements | Description | | Query Parameter | Requiered | Requirements | Description |
| --------------- | --------- | ------------ | ------------------------ | | --------------- | --------- | ------------ | ------------------------ |
| email | Yes | String | The user's email | | collectionId | Yes | String | Collection ID |
| token | Yes | String | The password reset token | | invitationId | No | String | Invitation ID |
| role | Yes | String | The role to search for: handlingEditor, reviewer, author |
#### User details response #### Get Invitations Response
```json ```javascript
HTTP/1.1 200 HTTP/1.1 200 OK
{ [
"firstName": "dsadasd", {
"lastName": "fisdadasdasdaasdago", "name": "John Smith",
"affiliation": "asdasasae23", "invitedOn": 1525428890167,
"title": "131sdadassa" "respondedOn": 1525428890299,
} "email": "email@example.com",
"status": "pending",
"invitationId": "1990881"
}
]
``` ```
--- ---
### Accept or Decline an Invitation [PATCH]
### Reset password [POST] This endpoint allows you to accept or to decline an invitation.
This endpoint will reset a user's password and confirm his account. #### Accept/Decline Request
#### Reset password request `PATCH /api/collections/:collectionId/invitations/:invitationId`
`POST /api/users/invite/password/reset` | URI Parameter | Requiered | Requirements | Description |
| --------------- | --------- | ------------ | ------------------------ |
| collectionId | Yes | String | Collection ID |
| invitationId | Yes | String | Invitation ID |
#### Reset password request body #### Accept/Decline Body
```json ```json
// All fields are required
{ {
"email": "new_user@domain.com", "isAccepted": false/true,
"token": "123", "reason": "I am not ready" [optional]
"firstName": "Marc",
"lastName": "Twain",
"title": "Prof",
"affiliation": "MIT",
"password": "verySecure"
} }
``` ```
#### Response #### Accept/Decline Response
```javascript
HTTP/1.1 200 OK
{
"id": "7b2431af-210c-49f9-a69a-e19271066ebd",
"role": "reviewer",
"userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
"hasAnswer": true,
"invitedOn": 1525428890167,
"isAccepted": false,
"respondedOn": 1525428890299
}
```
---
### Decline an Invitation Unauthenticated [PATCH]
This endpoint allows you to decline an invitation without authenticating.
#### Decline Request
`PATCH /api/collections/:collectionId/invitations/:invitationId/decline`
| URI Parameter | Requiered | Requirements | Description |
| --------------- | --------- | ------------ | ------------------------ |
| collectionId | Yes | String | Collection ID |
| invitationId | Yes | String | Invitation ID |
#### Decline Body
```json ```json
HTTP/1.1 200
{ {
"id": "37463722-c4ca-4e3c-acec-779df8c11ad2", "invitationToken": "f2d814f0-67a5-4590-ba4f-6a83565feb4f"
"username": "9a42b55f",
"email": "new_user@domain.com",
"isConfirmed": true,
"firstName": "Marc",
"lastName": "Twain",
"affiliation": "MIT",
"title": "Prof",
"admin": false,
"type": "user",
"roles": [
"editorInChief"
],
"collections": [],
"fragments": [],
"teams": [],
"rev": "2-81fb76ae72f143bb9edc2b4d4deaf7a3"
} }
``` ```
#### Decline Response
```javascript
HTTP/1.1 200 OK
{}
```
--- ---
### Delete Invitation [DELETE]
This endpoint allows you to delete an invitation.
#### Delete Invitation Request
`DELETE /api/collections/:collectionId/invitations/:invitationId`
| Query Parameter | Requiered | Requirements | Description |
| --------------- | --------- | ------------ | ------------------------ |
| collectionId | Yes | String | Collection ID |
| invitationId | Yes | String | Invitation ID |
#### Delete Invitation Response
```javascript
HTTP/1.1 204 No Content
```
\ No newline at end of file
...@@ -80,17 +80,18 @@ const setupReviewerDecisionEmailData = async ({ ...@@ -80,17 +80,18 @@ const setupReviewerDecisionEmailData = async ({
timestamp, timestamp,
}, },
}) })
await mailService.sendNotificationEmail({ if (agree)
toEmail: user.email, await mailService.sendNotificationEmail({
user, toEmail: user.email,
emailType: 'reviewer-thank-you', user,
meta: { emailType: 'reviewer-thank-you',
collection: { customId: collection.customId, id: collection.id }, meta: {
fragment: { id, title, authorName }, collection: { customId: collection.customId, id: collection.id },
handlingEditorName: collection.handlingEditor.name, fragment: { id, title, authorName },
baseUrl, handlingEditorName: collection.handlingEditor.name,
}, baseUrl,
}) },
})
} }
const setupReviewerUnassignEmail = async ({ const setupReviewerUnassignEmail = async ({
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment