user notifications auto created on login for joinging groups

This commit is contained in:
Henry Oswald 2016-02-17 16:24:09 +00:00
parent 8a417035ea
commit c8084406d3
5 changed files with 17 additions and 7 deletions

View file

@ -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) ->

View file

@ -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

View file

@ -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)->

View file

@ -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)->

View 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()