mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
skeleton of inviteToProject
function
This commit is contained in:
parent
e383e49161
commit
a4c7db5f20
1 changed files with 29 additions and 4 deletions
|
@ -1,11 +1,36 @@
|
|||
ProjectGetter = require "../Project/ProjectGetter"
|
||||
LimitationsManager = require "../Subscription/LimitationsManager"
|
||||
UserGetter = require "../User/UserGetter"
|
||||
CollaboratorsInviteHandler = require('./CollaboratorsInviteHandler')
|
||||
mimelib = require("mimelib")
|
||||
logger = require('logger-sharelatex')
|
||||
|
||||
module.exports = CollaboratorsInviteController =
|
||||
|
||||
inviteToProject: (req, res) ->
|
||||
inviteToProject: (req, res, next) ->
|
||||
projectId = req.params.Project_id
|
||||
email = req.body.email
|
||||
sendingUserId = req.session?.user_id
|
||||
logger.log {projectId, email, sendingUserId}, "inviting to project"
|
||||
LimitationsManager.canAddXCollaborators project_id, 1, (error, allowed) =>
|
||||
return next(error) if error?
|
||||
if !allowed
|
||||
logger.log {projectId, email, sendingUserId}, "not allowed to invite any more users to this project"
|
||||
return res.json {}
|
||||
{email, privileges} = req.body
|
||||
email = mimelib.parseAddresses(email or "")[0]?.address?.toLowerCase()
|
||||
if !email? or email == ""
|
||||
logger.log {projectId, email, sendingUserId}, "invalid email address"
|
||||
return res.status(400).send("invalid email address")
|
||||
CollaboratorsInviteHandler.inviteToProject projectId, sendingUserId, email, priveleges, (err, invite) ->
|
||||
if err?
|
||||
logger.err {projectId, email, sendingUserId}, "error creating project invite"
|
||||
return next(err)
|
||||
logger.log {projectId, email, sendingUserId}, "invite created"
|
||||
return res.json {inviteId: invite._id}
|
||||
|
||||
revokeInvite: (req, res) ->
|
||||
revokeInvite: (req, res, next) ->
|
||||
|
||||
viewInvite: (req, res) ->
|
||||
viewInvite: (req, res, next) ->
|
||||
|
||||
acceptInvite: (req, res) ->
|
||||
acceptInvite: (req, res, next) ->
|
||||
|
|
Loading…
Reference in a new issue