mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
moved delete user to the user controller
This commit is contained in:
parent
5f72f13528
commit
c55c5032b0
5 changed files with 40 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
UserGetter = require "./UserGetter"
|
||||
logger = require("logger-sharelatex")
|
||||
UserDeleter = require("./UserDeleter")
|
||||
|
||||
module.exports = UserController =
|
||||
getLoggedInUsersPersonalInfo: (req, res, next = (error) ->) ->
|
||||
|
@ -24,6 +25,13 @@ module.exports = UserController =
|
|||
return next(error) if error?
|
||||
res.send JSON.stringify(info)
|
||||
|
||||
deleteUser: (req, res)->
|
||||
user_id = req.session.user._id
|
||||
UserDeleter.deleteUser user_id, (err)->
|
||||
if !err?
|
||||
req.session.destroy()
|
||||
res.send(200)
|
||||
|
||||
_formatPersonalInfo: (user, callback = (error, info) ->) ->
|
||||
callback null, {
|
||||
id: user._id.toString()
|
||||
|
@ -33,3 +41,5 @@ module.exports = UserController =
|
|||
signUpDate: user.signUpDate
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,4 +25,5 @@ module.exports =
|
|||
|
||||
passwordResetPage : (req, res)->
|
||||
res.render 'user/passwordReset',
|
||||
title: 'Password Reset',
|
||||
title: 'Password Reset'
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ DropboxUserController = require("./Features/Dropbox/DropboxUserController")
|
|||
logger = require("logger-sharelatex")
|
||||
_ = require("underscore")
|
||||
|
||||
console.log PersonalInfoController
|
||||
|
||||
httpAuth = require('express').basicAuth (user, pass)->
|
||||
isValid = Settings.httpAuthUsers[user] == pass
|
||||
if !isValid
|
||||
|
@ -80,7 +82,7 @@ module.exports = class Router
|
|||
app.get '/user/passwordreset', UserPagesController.passwordResetPage
|
||||
app.post '/user/passwordReset', UserController.doRequestPasswordReset
|
||||
app.del '/user/newsletter/unsubscribe', AuthenticationController.requireLogin(), UserController.unsubscribe
|
||||
app.del '/user', AuthenticationController.requireLogin(), UserController.deleteUser
|
||||
app.del '/user', AuthenticationController.requireLogin(), PersonalInfoController.deleteUser
|
||||
|
||||
app.get '/dropbox/beginAuth', DropboxUserController.redirectUserToDropboxAuth
|
||||
app.get '/dropbox/completeRegistration', DropboxUserController.completeDropboxRegistration
|
||||
|
|
|
@ -11,8 +11,12 @@ ObjectId = require("mongojs").ObjectId
|
|||
|
||||
describe "UserController", ->
|
||||
beforeEach ->
|
||||
@UserDeleter =
|
||||
deleteUser: sinon.stub().callsArgWith(1)
|
||||
@UserController = SandboxedModule.require modulePath, requires:
|
||||
"./UserGetter": @UserGetter = {}
|
||||
"./UserDeleter": @UserDeleter
|
||||
|
||||
@req = new MockRequest()
|
||||
@res = new MockResponse()
|
||||
@next = sinon.stub()
|
||||
|
@ -103,3 +107,21 @@ describe "UserController", ->
|
|||
signUpDate: @user.signUpDate
|
||||
}
|
||||
|
||||
|
||||
describe "deleteUser", ->
|
||||
|
||||
it "should delete the user", (done)->
|
||||
user_id = "323123"
|
||||
@req.session.user =
|
||||
_id = user_id
|
||||
@res.send = (code)=>
|
||||
@UserDeleter.deleteUser.calledWith(user_id)
|
||||
code.should.equal 200
|
||||
done()
|
||||
@UserController.deleteUser @req, @res
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ describe "UserPagesController", ->
|
|||
beforeEach ->
|
||||
|
||||
@settings = {}
|
||||
|
||||
@UserPagesController = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex":@settings
|
||||
"logger-sharelatex": log:->
|
||||
|
@ -88,3 +89,5 @@ describe "UserPagesController", ->
|
|||
@UserPagesController.passwordResetPage @req, @res
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue