mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
idendifyUser on login
This commit is contained in:
parent
f910bb58de
commit
ebdce6169e
3 changed files with 9 additions and 2 deletions
|
@ -16,14 +16,15 @@ makeRequest = (opts, callback)->
|
|||
|
||||
module.exports =
|
||||
|
||||
idendifyUser: (user_id, old_user_id, callback)->
|
||||
idendifyUser: (user_id, old_user_id, callback = (error)->)->
|
||||
opts =
|
||||
body:
|
||||
old_user_id:old_user_id
|
||||
json:true
|
||||
method:"POST"
|
||||
timeout:1000
|
||||
url: "/user/#{user_id}/idendify"
|
||||
url: "/user/#{user_id}/identify"
|
||||
makeRequest opts, callback
|
||||
|
||||
recordEvent: (user_id, event, segmentation = {}, callback = (error) ->) ->
|
||||
if user_id+"" == settings.smokeTest?.userId+""
|
||||
|
|
|
@ -87,6 +87,7 @@ module.exports = AuthenticationController =
|
|||
LoginRateLimiter.recordSuccessfulLogin(email)
|
||||
AuthenticationController._recordSuccessfulLogin(user._id)
|
||||
Analytics.recordEvent(user._id, "user-logged-in", {ip:req.ip})
|
||||
Analytics.idendifyUser(user._id, req.sessionID)
|
||||
logger.log email: email, user_id: user._id.toString(), "successful log in"
|
||||
req.session.justLoggedIn = true
|
||||
# capture the request ip for use when creating the session
|
||||
|
|
|
@ -254,6 +254,8 @@ describe "AuthenticationController", ->
|
|||
@cb = sinon.stub()
|
||||
@LoginRateLimiter.processLoginRequest.callsArgWith(1, null, true)
|
||||
@AuthenticationManager.authenticate = sinon.stub().callsArgWith(2, null, @user)
|
||||
@req.sessionID = Math.random()
|
||||
@AnalyticsManager.idendifyUser = sinon.stub()
|
||||
@AuthenticationController.doPassportLogin(@req, @req.body.email, @req.body.password, @cb)
|
||||
|
||||
it "should attempt to authorise the user", ->
|
||||
|
@ -261,6 +263,9 @@ describe "AuthenticationController", ->
|
|||
.calledWith(email: @email.toLowerCase(), @password)
|
||||
.should.equal true
|
||||
|
||||
it "should call idendifyUser", ->
|
||||
@AnalyticsManager.idendifyUser.calledWith(@user._id, @req.sessionID).should.equal true
|
||||
|
||||
it "should setup the user data in the background", ->
|
||||
@UserHandler.setupLoginData.calledWith(@user).should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue