Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
49b9f1e9
Commit
49b9f1e9
authored
6 years ago
by
Alexandru Munteanu
Browse files
Options
Downloads
Plain Diff
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
!10
Sprint #12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-invite/README.md
+103
-98
103 additions, 98 deletions
packages/component-invite/README.md
packages/component-invite/src/helpers/User.js
+12
-11
12 additions, 11 deletions
packages/component-invite/src/helpers/User.js
with
115 additions
and
109 deletions
packages/component-invite/README.md
+
103
−
98
View file @
49b9f1e9
# 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-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.
#### Invite User Request
### 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 |
| ------------- | --------- | ------------ | ------------------ |
| collectionId | No | String | The ID of the collection |
#### Invite
r
equest
b
ody
#### Invite
User R
equest
B
ody
```
json
{
"email"
:
"new_user@domain.com"
/*
required
*/
,
"role"
:
"editorInChief"
/*
required
*/
,
"firstName"
:
"Marc"
,
"lastName"
:
"Twain"
,
"title"
:
"Prof"
,
"affiliation"
:
"MIT"
"email"
:
"email@example.com"
,
"role"
:
"handlingEditor"
,
[
acceptedValues:
handlingEditor
,
reviewer
]
}
```
#### Invite
u
ser
r
esponse
#### Invite
U
ser
R
esponse
```
j
son
HTTP/
1.1
200
```
j
avascript
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
,
"type"
:
"user"
,
"rev"
:
"1-12ebbb6686614791bb08ead305cde4f8"
}
"
id
"
:
"
7b2431af-210c-49f9-a69a-e19271066ebd
"
,
"
role
"
:
"
handlingEditor
"
,
"
userId
"
:
"
4c3f8ee1-785b-4adb-87b4-407a27f652c6
"
,
"
hasAnswer
"
:
false
,
"
invitedOn
"
:
1525428890167
,
"
isAccepted
"
:
false
,
"
respondedOn
"
:
null
}
```
---
###
R
et
rieve invited user detail
s [GET]
###
G
et
Invitation
s [GET]
This endpoint allows you to
r
et
rieve an invited users' details so that you can display them in the confirmation form
.
This endpoint allows you to
g
et
a list of invitations based on role
.
####
User detail
s
r
equest
####
Get Invitation
s
R
equest
`GET /api/
users/invite?email=new_user@domain.com&token=123
`
`GET /api/
collections/:collectionId/invitations/:invitationId?role=:role
`
| Query Parameter | Requiered | Requirements | Description |
| --------------- | --------- | ------------ | ------------------------ |
| email | Yes | String | The user's email |
| token | Yes | String | The password reset token |
| collectionId | Yes | String | Collection ID |
| invitationId | No | String | Invitation ID |
| role | Yes | String | The role to search for: handlingEditor, reviewer, author |
####
User detail
s
r
esponse
####
Get Invitation
s
R
esponse
```
json
HTTP/
1.1
200
{
"firstName"
:
"dsadasd"
,
"lastName"
:
"fisdadasdasdaasdago"
,
"affiliation"
:
"asdasasae23"
,
"title"
:
"131sdadassa"
}
```
javascript
HTTP
/
1.1
200
OK
[
{
"
name
"
:
"
John Smith
"
,
"
invitedOn
"
:
1525428890167
,
"
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 b
ody
####
Accept/Decline B
ody
```
json
//
All
fields
are
required
{
"email"
:
"new_user@domain.com"
,
"token"
:
"123"
,
"firstName"
:
"Marc"
,
"lastName"
:
"Twain"
,
"title"
:
"Prof"
,
"affiliation"
:
"MIT"
,
"password"
:
"verySecure"
"isAccepted"
:
false
/
true
,
"reason"
:
"I am not ready"
[
optional
]
}
```
#### 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
HTTP/
1.1
200
{
"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
,
"type"
:
"user"
,
"roles"
:
[
"editorInChief"
],
"collections"
:
[],
"fragments"
:
[],
"teams"
:
[],
"rev"
:
"2-81fb76ae72f143bb9edc2b4d4deaf7a3"
"invitationToken": "f2d814f0-67a5-4590-ba4f-6a83565feb4f"
}
`
``
#
### Decline Response
`
``javascript
H
TTP/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
This diff is collapsed.
Click to expand it.
packages/component-invite/src/helpers/User.js
+
12
−
11
View file @
49b9f1e9
...
...
@@ -80,17 +80,18 @@ const setupReviewerDecisionEmailData = async ({
timestamp
,
},
})
await
mailService
.
sendNotificationEmail
({
toEmail
:
user
.
email
,
user
,
emailType
:
'
reviewer-thank-you
'
,
meta
:
{
collection
:
{
customId
:
collection
.
customId
,
id
:
collection
.
id
},
fragment
:
{
id
,
title
,
authorName
},
handlingEditorName
:
collection
.
handlingEditor
.
name
,
baseUrl
,
},
})
if
(
agree
)
await
mailService
.
sendNotificationEmail
({
toEmail
:
user
.
email
,
user
,
emailType
:
'
reviewer-thank-you
'
,
meta
:
{
collection
:
{
customId
:
collection
.
customId
,
id
:
collection
.
id
},
fragment
:
{
id
,
title
,
authorName
},
handlingEditorName
:
collection
.
handlingEditor
.
name
,
baseUrl
,
},
})
}
const
setupReviewerUnassignEmail
=
async
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment