mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'sk-fix-password-set'
This commit is contained in:
commit
1d09fe2861
2 changed files with 25 additions and 12 deletions
|
@ -53,7 +53,11 @@ module.exports =
|
||||||
if req.body.login_after
|
if req.body.login_after
|
||||||
UserGetter.getUser user_id, {email: 1}, (err, user) ->
|
UserGetter.getUser user_id, {email: 1}, (err, user) ->
|
||||||
return next(err) if err?
|
return next(err) if err?
|
||||||
AuthenticationController.doLogin {email:user.email, password: password}, req, res, next
|
AuthenticationController.afterLoginSessionSetup req, user, (err) ->
|
||||||
|
if err?
|
||||||
|
logger.err {err, email: user.email}, "Error setting up session after setting password"
|
||||||
|
return next(err)
|
||||||
|
res.json {redir: AuthenticationController._getRedirectFromSession(req) || "/project"}
|
||||||
else
|
else
|
||||||
res.sendStatus 200
|
res.sendStatus 200
|
||||||
else
|
else
|
||||||
|
|
|
@ -145,18 +145,27 @@ describe "PasswordResetController", ->
|
||||||
done()
|
done()
|
||||||
@PasswordResetController.setNewUserPassword @req, @res
|
@PasswordResetController.setNewUserPassword @req, @res
|
||||||
|
|
||||||
it "should login user if login_after is set", (done) ->
|
describe 'when login_after is set', ->
|
||||||
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, { email: "joe@example.com" })
|
|
||||||
@PasswordResetHandler.setNewUserPassword.callsArgWith(2, null, true, @user_id = "user-id-123")
|
beforeEach ->
|
||||||
@req.body.login_after = "true"
|
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, { email: "joe@example.com" })
|
||||||
@AuthenticationController.doLogin = (options, req, res, next)=>
|
@PasswordResetHandler.setNewUserPassword.callsArgWith(2, null, true, @user_id = "user-id-123")
|
||||||
@UserGetter.getUser.calledWith(@user_id).should.equal true
|
@req.body.login_after = "true"
|
||||||
expect(options).to.deep.equal {
|
@res.json = sinon.stub()
|
||||||
email: "joe@example.com",
|
@AuthenticationController.afterLoginSessionSetup = sinon.stub().callsArgWith(2, null)
|
||||||
password: @password
|
@AuthenticationController._getRedirectFromSession = sinon.stub().returns('/some/path')
|
||||||
}
|
|
||||||
|
it "should login user if login_after is set", (done) ->
|
||||||
|
@PasswordResetController.setNewUserPassword @req, @res
|
||||||
|
@AuthenticationController.afterLoginSessionSetup.callCount.should.equal 1
|
||||||
|
@AuthenticationController.afterLoginSessionSetup.calledWith(
|
||||||
|
@req,
|
||||||
|
{email: 'joe@example.com'}
|
||||||
|
).should.equal true
|
||||||
|
@AuthenticationController._getRedirectFromSession.callCount.should.equal 1
|
||||||
|
@res.json.callCount.should.equal 1
|
||||||
|
@res.json.calledWith({redir: '/some/path'}).should.equal true
|
||||||
done()
|
done()
|
||||||
@PasswordResetController.setNewUserPassword @req, @res
|
|
||||||
|
|
||||||
describe "renderSetPasswordForm", ->
|
describe "renderSetPasswordForm", ->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue