mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-25 00:21:40 +00:00
Merge pull request #135 from sharelatex/ja-disable-account-settings-for-ol-v2
Enable the external auth switches when OL OAuth is in use
This commit is contained in:
commit
d3f146499c
3 changed files with 4 additions and 7 deletions
|
@ -51,7 +51,6 @@ module.exports = UserController =
|
|||
|
||||
updateUserSettings : (req, res)->
|
||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
usingExternalAuth = settings.ldap? or settings.saml?
|
||||
logger.log user_id: user_id, "updating account settings"
|
||||
User.findById user_id, (err, user)->
|
||||
if err? or !user?
|
||||
|
@ -84,7 +83,7 @@ module.exports = UserController =
|
|||
user.ace.syntaxValidation = req.body.syntaxValidation
|
||||
user.save (err)->
|
||||
newEmail = req.body.email?.trim().toLowerCase()
|
||||
if !newEmail? or newEmail == user.email or usingExternalAuth
|
||||
if !newEmail? or newEmail == user.email or req.externalAuthenticationSystemUsed()
|
||||
# end here, don't update email
|
||||
AuthenticationController.setInSessionUser(req, {first_name: user.first_name, last_name: user.last_name})
|
||||
return res.sendStatus 200
|
||||
|
|
|
@ -89,7 +89,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
|
||||
webRouter.use (req, res, next)->
|
||||
req.externalAuthenticationSystemUsed = res.locals.externalAuthenticationSystemUsed = ->
|
||||
Settings.ldap? or Settings.saml?
|
||||
Settings.ldap? or Settings.saml? or Settings.overleaf?.oauth?
|
||||
next()
|
||||
|
||||
webRouter.use (req, res, next)->
|
||||
|
|
|
@ -187,6 +187,7 @@ describe "UserController", ->
|
|||
describe "updateUserSettings", ->
|
||||
beforeEach ->
|
||||
@newEmail = "hello@world.com"
|
||||
@req.externalAuthenticationSystemUsed = sinon.stub().returns(false)
|
||||
|
||||
it "should call save", (done)->
|
||||
@req.body = {}
|
||||
|
@ -280,10 +281,7 @@ describe "UserController", ->
|
|||
beforeEach ->
|
||||
@UserUpdater.changeEmailAddress.callsArgWith(2)
|
||||
@newEmail = 'someone23@example.com'
|
||||
@settings.ldap = {active: true}
|
||||
|
||||
afterEach ->
|
||||
delete @settings.ldap
|
||||
@req.externalAuthenticationSystemUsed = sinon.stub().returns(true)
|
||||
|
||||
it 'should not set a new email', (done) ->
|
||||
@req.body.email = @newEmail
|
||||
|
|
Loading…
Reference in a new issue