mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
user notifications auto created on login for joinging groups
This commit is contained in:
parent
8a417035ea
commit
c8084406d3
5 changed files with 17 additions and 7 deletions
|
@ -8,7 +8,7 @@ querystring = require('querystring')
|
|||
Url = require("url")
|
||||
Settings = require "settings-sharelatex"
|
||||
basicAuth = require('basic-auth-connect')
|
||||
|
||||
UserHandler = require("../User/UserHandler")
|
||||
|
||||
module.exports = AuthenticationController =
|
||||
login: (req, res, next = (error) ->) ->
|
||||
|
@ -29,6 +29,7 @@ module.exports = AuthenticationController =
|
|||
AuthenticationManager.authenticate email: email, password, (error, user) ->
|
||||
return next(error) if error?
|
||||
if user?
|
||||
UserHandler.setupLoginData user, ->
|
||||
LoginRateLimiter.recordSuccessfulLogin email
|
||||
AuthenticationController._recordSuccessfulLogin user._id
|
||||
AuthenticationController.establishUserSession req, user, (error) ->
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports =
|
|||
messageOpts =
|
||||
groupName: licence.name
|
||||
subscription_id: licence.subscription_id
|
||||
NotificationsHandler.createNotification user._id, key, "joinSubscriptionInvite", messageOpts, callback
|
||||
NotificationsHandler.createNotification user._id, @key, "notification_group_invite", messageOpts, callback
|
||||
|
||||
read: (callback = ->)->
|
||||
NotificationsHandler.markAsReadWithKey user._id, key, callback
|
||||
NotificationsHandler.markAsReadWithKey user._id, @key, callback
|
||||
|
|
|
@ -30,6 +30,7 @@ module.exports =
|
|||
messageOpts:messageOpts
|
||||
templateKey:templateKey
|
||||
}
|
||||
logger.log opts:opts, "creating notification for user"
|
||||
request.post opts, callback
|
||||
|
||||
markAsReadWithKey: (user_id, key, callback)->
|
||||
|
|
|
@ -3,7 +3,6 @@ async = require("async")
|
|||
_ = require("underscore")
|
||||
settings = require("settings-sharelatex")
|
||||
SubscriptionGroupHandler = require("./SubscriptionGroupHandler")
|
||||
_s = require("underscore.string")
|
||||
|
||||
module.exports = SubscriptionDomainHandler =
|
||||
|
||||
|
@ -34,16 +33,13 @@ module.exports = SubscriptionDomainHandler =
|
|||
else
|
||||
return undefined
|
||||
|
||||
|
||||
autoAllocate: (user, callback = ->)->
|
||||
licence = SubscriptionDomainHandler._findDomainLicence(user.email)
|
||||
#
|
||||
if licence?
|
||||
SubscriptionGroupHandler.addUserToGroup licence.adminUser_id, user.email, callback
|
||||
else
|
||||
callback()
|
||||
|
||||
|
||||
_findDomainLicence: (email)->
|
||||
licence = _.find settings.domainLicences, (licence)->
|
||||
_.find licence.domains, (domain)->
|
||||
|
|
12
services/web/app/coffee/Features/User/UserHandler.coffee
Normal file
12
services/web/app/coffee/Features/User/UserHandler.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
SubscriptionDomainHandler = require("../Subscription/SubscriptionDomainHandler")
|
||||
NotificationsBuilder = require("../Notifications/NotificationsBuilder")
|
||||
|
||||
|
||||
module.exports =
|
||||
|
||||
setupLoginData: (user, callback = ->)->
|
||||
licence = SubscriptionDomainHandler.getLicenceUserCanJoin user
|
||||
if licence?
|
||||
NotificationsBuilder.groupPlan(user, licence).create(callback)
|
||||
else
|
||||
return callback()
|
Loading…
Reference in a new issue