mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
created new UserController and put delete user in it
This commit is contained in:
parent
37fb959b00
commit
823f4a5eb9
5 changed files with 51 additions and 25 deletions
10
services/web/app/coffee/Features/User/UserController.coffee
Normal file
10
services/web/app/coffee/Features/User/UserController.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
UserDeleter = require("./UserDeleter")
|
||||
|
||||
module.exports =
|
||||
|
||||
deleteUser: (req, res)->
|
||||
user_id = req.session.user._id
|
||||
UserDeleter.deleteUser user_id, (err)->
|
||||
if !err?
|
||||
req.session.destroy()
|
||||
res.send(200)
|
|
@ -25,13 +25,6 @@ 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()
|
||||
|
|
|
@ -24,6 +24,7 @@ AuthenticationController = require('./Features/Authentication/AuthenticationCont
|
|||
TagsController = require("./Features/Tags/TagsController")
|
||||
CollaboratorsController = require('./Features/Collaborators/CollaboratorsController')
|
||||
UserInfoController = require('./Features/User/UserInfoController')
|
||||
UserController_new = require("./Features/User/UserController")
|
||||
UserPagesController = require('./Features/User/UserPagesController')
|
||||
DocumentController = require('./Features/Documents/DocumentController')
|
||||
CompileManager = require("./Features/Compile/CompileManager")
|
||||
|
@ -80,7 +81,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(), UserInfoController.deleteUser
|
||||
app.del '/user', AuthenticationController.requireLogin(), UserController_new.deleteUser
|
||||
|
||||
app.get '/dropbox/beginAuth', DropboxUserController.redirectUserToDropboxAuth
|
||||
app.get '/dropbox/completeRegistration', DropboxUserController.completeDropboxRegistration
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
sinon = require('sinon')
|
||||
chai = require('chai')
|
||||
should = chai.should()
|
||||
expect = chai.expect
|
||||
modulePath = "../../../../app/js/Features/User/UserController.js"
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
events = require "events"
|
||||
MockResponse = require "../helpers/MockResponse"
|
||||
MockRequest = require "../helpers/MockRequest"
|
||||
ObjectId = require("mongojs").ObjectId
|
||||
|
||||
describe "UserController", ->
|
||||
beforeEach ->
|
||||
@UserDeleter =
|
||||
deleteUser: sinon.stub().callsArgWith(1)
|
||||
@UserController = SandboxedModule.require modulePath, requires:
|
||||
"./UserDeleter": @UserDeleter
|
||||
|
||||
@req = new MockRequest()
|
||||
@res = new MockResponse()
|
||||
@next = sinon.stub()
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -108,20 +108,3 @@ describe "UserInfoController", ->
|
|||
}
|
||||
|
||||
|
||||
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()
|
||||
@UserInfoController.deleteUser @req, @res
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue