mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 04:15:25 -05:00
Show team invites
This commit is contained in:
parent
7e09c0e0b1
commit
9aa95cb0d5
5 changed files with 60 additions and 35 deletions
|
@ -1,6 +1,7 @@
|
|||
logger = require("logger-sharelatex")
|
||||
TeamInvitesHandler = require('./TeamInvitesHandler')
|
||||
AuthenticationController = require("../Authentication/AuthenticationController")
|
||||
ErrorController = require("../Errors/ErrorController")
|
||||
|
||||
module.exports =
|
||||
createInvite: (req, res, next) ->
|
||||
|
@ -14,16 +15,23 @@ module.exports =
|
|||
}
|
||||
res.json inviteView
|
||||
|
||||
viewInvite: (req, res) ->
|
||||
token = request.params.token
|
||||
viewInvite: (req, res, next) ->
|
||||
token = req.params.token
|
||||
userId = AuthenticationController.getLoggedInUserId(req)
|
||||
|
||||
TeamInvitesHandler.getInvite token, (err, invite) ->
|
||||
TeamInvitesHandler.getInviteDetails token, userId, (err, results) ->
|
||||
next(err) if err?
|
||||
|
||||
res.render "referal/bonus",
|
||||
title: "bonus_please_recommend_us"
|
||||
refered_users: refered_users
|
||||
refered_user_count: (refered_users or []).length
|
||||
{ invite, personalSubscription, inviterName } = results
|
||||
|
||||
unless invite?
|
||||
return ErrorController.notFound(req, res, next)
|
||||
|
||||
res.render "subscriptions/group/team_invite",
|
||||
inviterName: inviterName
|
||||
inviteToken: invite.token
|
||||
hasPersonalSubscription: personalSubscription?
|
||||
|
||||
|
||||
acceptInvite: (req, res) ->
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = TeamInvitesHandler =
|
|||
SubscriptionLocator.getUsersSubscription adminUserId, (error, subscription) ->
|
||||
return callback(error) if error?
|
||||
|
||||
inviterName = "#{groupAdmin.first_name} #{groupAdmin.last_name}"
|
||||
inviterName = TeamInvitesHandler.inviterName(groupAdmin)
|
||||
token = crypto.randomBytes(32).toString("hex")
|
||||
|
||||
TeamInvite.create {
|
||||
|
@ -37,8 +37,35 @@ module.exports = TeamInvitesHandler =
|
|||
return callback(error, invite)
|
||||
|
||||
getInvite: (token, callback) ->
|
||||
|
||||
TeamInvite.findOne(token: token, callback)
|
||||
|
||||
acceptInvite: (userId, token, callback) ->
|
||||
|
||||
revokeInvite: (token, callback) ->
|
||||
|
||||
getInviteDetails: (token, userId, callback) ->
|
||||
TeamInvitesHandler.getInvite token, (err, invite) ->
|
||||
callback(err) if err?
|
||||
|
||||
SubscriptionLocator.getUsersSubscription userId, (err, personalSubscription) ->
|
||||
callback(err) if err?
|
||||
|
||||
SubscriptionLocator.getSubscription invite.subscriptionId, (err, teamSubscription) ->
|
||||
callback(err) if err?
|
||||
|
||||
UserLocator.findById teamSubscription.admin_id, (err, teamAdmin) ->
|
||||
callback(err) if err?
|
||||
|
||||
callback(null , {
|
||||
invite: invite,
|
||||
personalSubscription: personalSubscription,
|
||||
team: teamSubscription,
|
||||
inviterName: TeamInvitesHandler.inviterName(teamAdmin),
|
||||
teamAdmin: teamAdmin
|
||||
})
|
||||
|
||||
inviterName: (groupAdmin) ->
|
||||
if groupAdmin.first_name and groupAdmin.last_name
|
||||
"#{groupAdmin.first_name} #{groupAdmin.last_name} (#{groupAdmin.email})"
|
||||
else
|
||||
groupAdmin.email
|
||||
|
|
|
@ -4,10 +4,10 @@ block scripts
|
|||
script(type='text/javascript').
|
||||
window.teamId = '#{teamId}'
|
||||
window.hasPersonalSubscription = #{hasPersonalSubscription}
|
||||
window.inviteToken = #{inviteToken}
|
||||
window.inviteToken = '#{inviteToken}'
|
||||
|
||||
block content
|
||||
.content.content-alt
|
||||
.content.content-alt.team-invite
|
||||
.container
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
|
@ -20,36 +20,21 @@ block content
|
|||
.col-md-8.col-md-offset-2(ng-cloak)
|
||||
.card(ng-controller="TeamInviteController")
|
||||
.page-header
|
||||
h1.text-centered #{translate("you_are_invited_to_group", {teamName: teamName})}
|
||||
h1.text-centered #{translate("invited_to_group", {inviterName: inviterName})}
|
||||
|
||||
div(ng-show="view =='personalSubscription'").row.text-centered
|
||||
div #{translate("cancel_personal_subscription_first")}
|
||||
.row
|
||||
.col-md-12
|
||||
div(ng-show="view =='personalSubscription'").row.text-centered.message
|
||||
p #{translate("cancel_personal_subscription_first")}
|
||||
.row
|
||||
.col-md-12
|
||||
a.btn.btn.btn-default(ng-click="keepPersonalSubscription()", ng-disabled="inflight") #{translate("not_now")}
|
||||
span
|
||||
a.btn.btn.btn-primary(ng-click="cancelPersonalSubscription()", ng-disabled="inflight") #{translate("cancel_your_subscription")}
|
||||
|
||||
div(ng-show="view =='teamInvite'").row.text-centered
|
||||
.row
|
||||
.col-md-12 #{translate("group_provides_you_with_premium_account", {teamName: teamName})}
|
||||
.row
|
||||
.col-md-12
|
||||
div(ng-show="view =='teamInvite'").row.text-centered.message
|
||||
p #{translate("accept_invite_to_join_team", {inviterName: inviterName})}
|
||||
.row
|
||||
.col-md-12
|
||||
.text-center
|
||||
a.btn.btn-default(href="/project") #{translate("not_now")}
|
||||
span
|
||||
a.btn.btn.btn-primary(ng-click="joinTeam()", ng-disabled="inflight") #{translate("verify_email_address")}
|
||||
|
||||
|
||||
span(ng-show="view =='requestSent'").row.text-centered.text-center
|
||||
.row
|
||||
.col-md-12 #{translate("check_email_to_complete_the_upgrade")}
|
||||
.row
|
||||
.col-md-12
|
||||
.row
|
||||
.col-md-12
|
||||
a.btn.btn.btn-primary(href="/project") #{translate("done")}
|
||||
a.btn.btn.btn-primary(ng-click="joinTeam()", ng-disabled="inflight") #{translate("join_team")}
|
||||
|
|
|
@ -17,6 +17,7 @@ define [
|
|||
"main/announcements"
|
||||
"main/register-users"
|
||||
"main/subscription/group-subscription-invite-controller"
|
||||
"main/subscription/team-invite-controller"
|
||||
"main/contact-us"
|
||||
"main/learn"
|
||||
"analytics/AbTestingManager"
|
||||
|
|
|
@ -73,6 +73,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.team-invite .message {
|
||||
margin: 3em 0;
|
||||
}
|
||||
|
||||
.capitalised {
|
||||
text-transform:capitalize;
|
||||
}
|
Loading…
Reference in a new issue