mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
moved user settings page to the user pages controller
This commit is contained in:
parent
823f4a5eb9
commit
12773c26c2
5 changed files with 59 additions and 34 deletions
|
@ -1,4 +1,8 @@
|
||||||
|
UserLocator = require("./UserLocator")
|
||||||
|
dropboxHandler = require('../Dropbox/DropboxHandler')
|
||||||
|
logger = require("logger-sharelatex")
|
||||||
|
Settings = require("settings-sharelatex")
|
||||||
|
fs = require('fs')
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
||||||
|
@ -27,3 +31,28 @@ module.exports =
|
||||||
res.render 'user/passwordReset',
|
res.render 'user/passwordReset',
|
||||||
title: 'Password Reset'
|
title: 'Password Reset'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
settingsPage : (req, res)->
|
||||||
|
logger.log user: req.session.user, "loading settings page"
|
||||||
|
UserLocator.findById req.session.user._id, (err, user)->
|
||||||
|
dropboxHandler.getUserRegistrationStatus user._id, (err, status)->
|
||||||
|
userIsRegisteredWithDropbox = !err? and status.registered
|
||||||
|
res.render 'user/settings',
|
||||||
|
title:'Your settings',
|
||||||
|
userHasDropboxFeature: user.features.dropbox
|
||||||
|
userIsRegisteredWithDropbox: userIsRegisteredWithDropbox
|
||||||
|
user: user,
|
||||||
|
themes: THEME_LIST,
|
||||||
|
editors: ['default','vim','emacs'],
|
||||||
|
fontSizes: ['10','11','12','13','14','16','20','24']
|
||||||
|
languages: Settings.languages,
|
||||||
|
accountSettingsTabActive: true
|
||||||
|
|
||||||
|
THEME_LIST = []
|
||||||
|
do generateThemeList = () ->
|
||||||
|
files = fs.readdirSync __dirname + '/../../../../public/js/ace/theme'
|
||||||
|
for file in files
|
||||||
|
if file.slice(-2) == "js"
|
||||||
|
cleanName = file.slice(0,-3)
|
||||||
|
THEME_LIST.push name: cleanName
|
|
@ -105,22 +105,6 @@ module.exports =
|
||||||
logger.err err: err, 'error destorying session'
|
logger.err err: err, 'error destorying session'
|
||||||
res.redirect '/login'
|
res.redirect '/login'
|
||||||
|
|
||||||
settings : (req, res)->
|
|
||||||
logger.log user: req.session.user, "loading settings page"
|
|
||||||
User.findById req.session.user._id, (err, user)->
|
|
||||||
dropboxHandler.getUserRegistrationStatus user._id, (err, status)->
|
|
||||||
userIsRegisteredWithDropbox = !err? and status.registered
|
|
||||||
res.render 'user/settings',
|
|
||||||
title:'Your settings',
|
|
||||||
userCanSeeDropbox: user.featureSwitches.dropbox
|
|
||||||
userHasDropboxFeature: user.features.dropbox
|
|
||||||
userIsRegisteredWithDropbox: userIsRegisteredWithDropbox
|
|
||||||
user: user,
|
|
||||||
themes: THEME_LIST,
|
|
||||||
editors: ['default','vim','emacs'],
|
|
||||||
fontSizes: ['10','11','12','13','14','16','20','24']
|
|
||||||
languages: Settings.languages,
|
|
||||||
accountSettingsTabActive: true
|
|
||||||
|
|
||||||
unsubscribe: (req, res)->
|
unsubscribe: (req, res)->
|
||||||
User.findById req.session.user._id, (err, user)->
|
User.findById req.session.user._id, (err, user)->
|
||||||
|
@ -183,10 +167,4 @@ module.exports =
|
||||||
res.send(200)
|
res.send(200)
|
||||||
|
|
||||||
|
|
||||||
THEME_LIST = []
|
|
||||||
do generateThemeList = () ->
|
|
||||||
files = fs.readdirSync __dirname + '/../../../public/js/ace/theme'
|
|
||||||
for file in files
|
|
||||||
if file.slice(-2) == "js"
|
|
||||||
cleanName = file.slice(0,-3)
|
|
||||||
THEME_LIST.push name: cleanName
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ module.exports = class Router
|
||||||
if Settings.enableSubscriptions
|
if Settings.enableSubscriptions
|
||||||
app.get '/user/bonus', AuthenticationController.requireLogin(), ReferalMiddleware.getUserReferalId, ReferalController.bonus
|
app.get '/user/bonus', AuthenticationController.requireLogin(), ReferalMiddleware.getUserReferalId, ReferalController.bonus
|
||||||
|
|
||||||
app.get '/user/settings', AuthenticationController.requireLogin(), UserController.settings
|
app.get '/user/settings', AuthenticationController.requireLogin(), UserPagesController.settingsPage
|
||||||
app.post '/user/settings', AuthenticationController.requireLogin(), UserController.apiUpdate
|
app.post '/user/settings', AuthenticationController.requireLogin(), UserController.apiUpdate
|
||||||
app.post '/user/password/update', AuthenticationController.requireLogin(), UserController.changePassword
|
app.post '/user/password/update', AuthenticationController.requireLogin(), UserController.changePassword
|
||||||
app.get '/user/passwordreset', UserPagesController.passwordResetPage
|
app.get '/user/passwordreset', UserPagesController.passwordResetPage
|
||||||
|
|
|
@ -11,10 +11,10 @@ ObjectId = require("mongojs").ObjectId
|
||||||
|
|
||||||
describe "UserController", ->
|
describe "UserController", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@UserDeleter =
|
|
||||||
deleteUser: sinon.stub().callsArgWith(1)
|
|
||||||
@UserController = SandboxedModule.require modulePath, requires:
|
@UserController = SandboxedModule.require modulePath, requires:
|
||||||
"./UserDeleter": @UserDeleter
|
"./UserDeleter": @UserDeleter
|
||||||
|
"logger-sharelatex": {log:->}
|
||||||
|
|
||||||
|
|
||||||
@req = new MockRequest()
|
@req = new MockRequest()
|
||||||
@res = new MockResponse()
|
@res = new MockResponse()
|
||||||
|
@ -33,7 +33,3 @@ describe "UserController", ->
|
||||||
@UserController.deleteUser @req, @res
|
@UserController.deleteUser @req, @res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,25 @@ describe "UserPagesController", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
||||||
@settings = {}
|
@settings = {}
|
||||||
|
@user =
|
||||||
|
_id:"kwjewkl"
|
||||||
|
features:{}
|
||||||
|
@UserDeleter =
|
||||||
|
deleteUser: sinon.stub().callsArgWith(1)
|
||||||
|
@UserLocator =
|
||||||
|
findById: sinon.stub().callsArgWith(1, null, @user)
|
||||||
|
@dropboxStatus = {}
|
||||||
|
@DropboxHandler =
|
||||||
|
getUserRegistrationStatus : sinon.stub().callsArgWith(1, null, @dropboxStatus)
|
||||||
@UserPagesController = SandboxedModule.require modulePath, requires:
|
@UserPagesController = SandboxedModule.require modulePath, requires:
|
||||||
"settings-sharelatex":@settings
|
"settings-sharelatex":@settings
|
||||||
"logger-sharelatex": log:->
|
"logger-sharelatex": log:->
|
||||||
|
"./UserLocator": @UserLocator
|
||||||
|
'../Dropbox/DropboxHandler': @DropboxHandler
|
||||||
@req =
|
@req =
|
||||||
query:{}
|
query:{}
|
||||||
session:{}
|
session:
|
||||||
|
user:@user
|
||||||
@res = {}
|
@res = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,5 +100,16 @@ describe "UserPagesController", ->
|
||||||
@UserPagesController.passwordResetPage @req, @res
|
@UserPagesController.passwordResetPage @req, @res
|
||||||
|
|
||||||
|
|
||||||
|
describe "settingsPage", ->
|
||||||
|
|
||||||
|
it "should render user/settings", (done)->
|
||||||
|
@res.render = (page)->
|
||||||
|
page.should.equal "user/settings"
|
||||||
|
done()
|
||||||
|
@UserPagesController.settingsPage @req, @res
|
||||||
|
|
||||||
|
it "should send user", (done)->
|
||||||
|
@res.render = (page, opts)=>
|
||||||
|
opts.user.should.equal @user
|
||||||
|
done()
|
||||||
|
@UserPagesController.settingsPage @req, @res
|
Loading…
Reference in a new issue