mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
added referal allocator to user controller
This commit is contained in:
parent
c2cb6e2c1f
commit
aca2e5639e
2 changed files with 19 additions and 0 deletions
|
@ -9,6 +9,7 @@ metrics = require("../../infrastructure/Metrics")
|
|||
Url = require("url")
|
||||
AuthenticationController = require("../Authentication/AuthenticationController")
|
||||
AuthenticationManager = require("../Authentication/AuthenticationManager")
|
||||
ReferalAllocator = require("../Referal/ReferalAllocator")
|
||||
|
||||
module.exports =
|
||||
|
||||
|
@ -61,6 +62,7 @@ module.exports =
|
|||
metrics.inc "user.register.success"
|
||||
req.session.user = user
|
||||
req.session.justRegistered = true
|
||||
ReferalAllocator.allocate req.session.referal_id, user._id, req.session.referal_source, req.session.referal_medium
|
||||
res.send
|
||||
redir:redir
|
||||
id:user._id.toString()
|
||||
|
@ -69,6 +71,7 @@ module.exports =
|
|||
email: user.email
|
||||
created: Date.now()
|
||||
|
||||
|
||||
changePassword : (req, res, next = (error) ->)->
|
||||
metrics.inc "user.password-change"
|
||||
oldPass = req.body.currentPassword
|
||||
|
|
|
@ -33,6 +33,8 @@ describe "UserController", ->
|
|||
@AuthenticationManager =
|
||||
authenticate: sinon.stub()
|
||||
setUserPassword: sinon.stub()
|
||||
@ReferalAllocator =
|
||||
allocate:sinon.stub()
|
||||
@UserController = SandboxedModule.require modulePath, requires:
|
||||
"./UserLocator": @UserLocator
|
||||
"./UserDeleter": @UserDeleter
|
||||
|
@ -41,6 +43,7 @@ describe "UserController", ->
|
|||
"./UserRegistrationHandler":@UserRegistrationHandler
|
||||
"../Authentication/AuthenticationController": @AuthenticationController
|
||||
"../Authentication/AuthenticationManager": @AuthenticationManager
|
||||
"../Referal/ReferalAllocator":@ReferalAllocator
|
||||
"logger-sharelatex": {log:->}
|
||||
|
||||
|
||||
|
@ -151,6 +154,19 @@ describe "UserController", ->
|
|||
done()
|
||||
@UserController.register @req, @res
|
||||
|
||||
it "should allocate the referals", (done)->
|
||||
@req.session =
|
||||
referal_id : "23123"
|
||||
referal_source : "email"
|
||||
referal_medium : "bob"
|
||||
|
||||
@UserRegistrationHandler.registerNewUser.callsArgWith(1, null, @user)
|
||||
@req.body.redir = "/somewhere"
|
||||
@res.send = (opts)=>
|
||||
@ReferalAllocator.allocate.calledWith(@req.session.referal_id, @user._id, @req.session.referal_source, @req.session.referal_medium).should.equal true
|
||||
done()
|
||||
@UserController.register @req, @res
|
||||
|
||||
|
||||
|
||||
describe "changePassword", ->
|
||||
|
|
Loading…
Reference in a new issue