diff --git a/packages/component-user-manager/README.md b/packages/component-user-manager/README.md index fcc89449e6ada94cfa3c2db93293996cacfe8ad8..02ddd09dde6803ffa07b4da0bbaae4213495ec92 100644 --- a/packages/component-user-manager/README.md +++ b/packages/component-user-manager/README.md @@ -1,149 +1,227 @@ -# Invite Component +# User Manager Component -## Configuration +### Add Author 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 Author, linking it to a Collection through a Team. -```json - { - '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. +#### Add Author Request -### Upload a file [POST] +`POST /api/collections/:collectionId/users` -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 | | ------------- | --------- | ------------ | ------------------ | | collectionId | No | String | The ID of the collection | -#### Invite request body +#### Add Author Body ```json { - "email": "new_user@domain.com" /* required */, - "role": "editorInChief" /* required */, - "firstName": "Marc", - "lastName": "Twain", - "title": "Prof", - "affiliation": "MIT" + "email": "email@example.com", + "role": "author", [acceptedValues: author], + "isSubmitting": true, + "isCorresponding": false } ``` -#### Invite user response +#### Add Author Response -```json -HTTP/1.1 200 +```javascript +HTTP/1.1 200 OK { - "id": "37463722-c4ca-4e3c-acec-779df8c11ad2", - "username": "9a42b55f", - "email": "new_user@domain.com", - "roles": ["editorInChief"], - "passwordResetToken": "123", - "isConfirmed": false, - "firstName": "Marc", - "lastName": "Twain", - "affiliation": "MIT", - "title": "Prof", - "admin": false, + "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", "type": "user", - "rev": "1-12ebbb6686614791bb08ead305cde4f8" + "admin": false, + "email": "email@example.com", + "teams": [ + "c576695a-7cda-4e27-8e9c-31f3a0e9d592" + ], + "username": "email@example.com", + "fragments": [], + "collections": [], + "isConfirmed": false, + "editorInChief": false, + "handlingEditor": false, + "passwordResetToken": "04590a2b7f6c1f37cb84881d529e516fa6fc309c205a07f1341b2bfaa6f2b46c" } ``` --- -### Retrieve invited user details [GET] +### Get Collection Authors [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 authors for a collection. -#### User details request +#### Get Collection Authors Request -`GET /api/users/invite?email=new_user@domain.com&token=123` +`GET /api/collections/:collectionId/users` | Query Parameter | Requiered | Requirements | Description | | --------------- | --------- | ------------ | ------------------------ | -| email | Yes | String | The user's email | -| token | Yes | String | The password reset token | +| collectionId | Yes | String | Collection ID | + +#### Get Collection Authors Response + +```javascript +HTTP/1.1 200 OK +[ + { + "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", + "type": "user", + "admin": false, + "email": "email@example.com", + "teams": [ + "c576695a-7cda-4e27-8e9c-31f3a0e9d592" + ], + "username": "email@example.com", + "fragments": [], + "collections": [], + "isConfirmed": false, + "editorInChief": false, + "handlingEditor": false, + "passwordResetToken": "04590a2b7f6c1f37cb84881d529e516fa6fc309c205a07f1341b2bfaa6f2b46c", + "isSubmitting": true, + "isCorresponding": false, + }, + { + "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", + "type": "user", + "admin": false, + "email": "email2@example.com", + "teams": [ + "c576695a-7cda-4e27-8e9c-31f3a0e9d592" + ], + "username": "email2@example.com", + "fragments": [], + "collections": [], + "isConfirmed": true, + "editorInChief": false, + "handlingEditor": false, + "isSubmitting": false, + "isCorresponding": false, + } +] +``` + +--- +### Update Author [PATCH] + +This endpoint allows you to update an author's data. + +#### Update Author Request + +`PATCH /api/collections/:collectionId/invitations/:invitationId` + +| URI Parameter | Requiered | Requirements | Description | +| --------------- | --------- | ------------ | ------------------------ | +| collectionId | Yes | String | Collection ID | +| userId | Yes | String | User ID | -#### User details response +#### Update Author Body ```json -HTTP/1.1 200 { - "firstName": "dsadasd", - "lastName": "fisdadasdasdaasdago", - "affiliation": "asdasasae23", - "title": "131sdadassa" + "isSubmitting": false, + "isCorresponding": true, + "firstName": "John", + "lastName": "Smith", + "affiliation": "UCLA" } ``` +#### Update Author Response + +```javascript +HTTP/1.1 200 OK +{ + "id": "7e8a77f9-8e5c-4fa3-b717-8df9932df128", + "type": "collection", + "owners": [ + { + "id": "69ac1ee9-08a8-4ee6-a57c-c6c8be8d3c4f", + "username": "admin" + } + ], + "authors": [ + { + "userId": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", + "isSubmitting": false, + "isCorresponding": true + } + ], + "created": 1522829424474, + "customId": "9424466", + "fragments": [ + "c35d0bd8-be03-4c16-b869-bd69796c5a21" + ], + "invitations": [ + { + "id": "9043a836-0d49-4b8d-be0b-df39071b5c57", + "hasAnswer": false, + "timestamp": 1522831123430, + "isAccepted": false + }, + ] +} +``` --- +### Delete Author [DELETE] -### Reset password [POST] +This endpoint allows you to delete an author from a collection. -This endpoint will reset a user's password and confirm his account. +#### Delete Author Request + +`DELETE /api/collections/:collectionId/users/:userId` + +| Query Parameter | Requiered | Requirements | Description | +| --------------- | --------- | ------------ | ------------------------ | +| collectionId | Yes | String | Collection ID | +| userId | Yes | String | User ID | + +#### Delete Author Response + +```javascript +HTTP/1.1 200 OK +{} +``` +--- +### Reset Password [POST] -#### Reset password request +This endpoint allows you to reset your password. -`POST /api/users/invite/password/reset` +#### Reset Password Request -#### Reset password request body +`POST /api/users/reset-password` + + +#### Reset Password Body ```json -// All fields are required { - "email": "new_user@domain.com", - "token": "123", - "firstName": "Marc", - "lastName": "Twain", - "title": "Prof", - "affiliation": "MIT", - "password": "verySecure" + "email": "email@example.com", + "token": "123123123", + "password": "password", + "firstName": "John", + "lastName": "Smith", + "affiliation": "UCLA", + "title": "Mr" } ``` -#### Response +#### Reset Password Response -```json -HTTP/1.1 200 +```javascript +HTTP/1.1 200 OK { - "id": "37463722-c4ca-4e3c-acec-779df8c11ad2", - "username": "9a42b55f", - "email": "new_user@domain.com", - "isConfirmed": true, - "firstName": "Marc", - "lastName": "Twain", - "affiliation": "MIT", - "title": "Prof", - "admin": false, + "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", "type": "user", - "roles": [ - "editorInChief" - ], - "collections": [], - "fragments": [], + "admin": false, + "email": "email@example.com", "teams": [], - "rev": "2-81fb76ae72f143bb9edc2b4d4deaf7a3" + "username": "email@example.com", + "fragments": [], + "collections": [], + "isConfirmed": true, + "editorInChief": false, + "handlingEditor": false } -``` - ---- +``` \ No newline at end of file diff --git a/packages/component-user-manager/src/CollectionsUsers.js b/packages/component-user-manager/src/CollectionsUsers.js index 8258226387f677c4a30c64643b15fded95ed1ef8..5ee6f750ff770c0b83fbaad57537206c54aa82f1 100644 --- a/packages/component-user-manager/src/CollectionsUsers.js +++ b/packages/component-user-manager/src/CollectionsUsers.js @@ -81,7 +81,9 @@ const CollectionsUsers = app => { * "isConfirmed": false, * "editorInChief": false, * "handlingEditor": false, - * "passwordResetToken": "04590a2b7f6c1f37cb84881d529e516fa6fc309c205a07f1341b2bfaa6f2b46c" + * "passwordResetToken": "04590a2b7f6c1f37cb84881d529e516fa6fc309c205a07f1341b2bfaa6f2b46c", + * "isSubmitting": true, + * "isCorresponding": false, * }, * { * "id": "a6184463-b17a-42f8-b02b-ae1d755cdc6b", @@ -96,7 +98,9 @@ const CollectionsUsers = app => { * "collections": [], * "isConfirmed": true, * "editorInChief": false, - * "handlingEditor": false, + * "handlingEditor": false", + * "isSubmitting": false, + * "isCorresponding": false, * }] * @apiErrorExample {json} List errors * HTTP/1.1 400 Bad Request