mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
moved register page to new UserPagesController
This commit is contained in:
parent
c163bba1da
commit
fa36891faf
4 changed files with 91 additions and 19 deletions
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
|
||||||
|
registerPage : (req, res)->
|
||||||
|
|
||||||
|
sharedProjectData =
|
||||||
|
project_name:req.query.project_name
|
||||||
|
user_first_name:req.query.user_first_name
|
||||||
|
|
||||||
|
newTemplateData = {}
|
||||||
|
if req.session.templateData?
|
||||||
|
newTemplateData.templateName = req.session.templateData.templateName
|
||||||
|
|
||||||
|
res.render 'user/register',
|
||||||
|
title: 'Register'
|
||||||
|
redir: req.query.redir
|
||||||
|
sharedProjectData: sharedProjectData
|
||||||
|
newTemplateData: newTemplateData
|
||||||
|
new_email:req.query.new_email || ""
|
|
@ -20,24 +20,6 @@ uuid = require("node-uuid")
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
||||||
registerForm : (req, res)->
|
|
||||||
|
|
||||||
sharedProjectData =
|
|
||||||
project_name:req.query.project_name
|
|
||||||
user_first_name:req.query.user_first_name
|
|
||||||
|
|
||||||
newTemplateData = {}
|
|
||||||
if req.session.templateData?
|
|
||||||
newTemplateData.templateName = req.session.templateData.templateName
|
|
||||||
|
|
||||||
res.render 'user/register',
|
|
||||||
title: 'Register'
|
|
||||||
redir: req.query.redir
|
|
||||||
sharedProjectData: sharedProjectData
|
|
||||||
newTemplateData: newTemplateData
|
|
||||||
new_email:req.query.new_email || ""
|
|
||||||
|
|
||||||
|
|
||||||
loginForm : (req, res)->
|
loginForm : (req, res)->
|
||||||
res.render 'user/login',
|
res.render 'user/login',
|
||||||
title: 'Login',
|
title: 'Login',
|
||||||
|
|
|
@ -24,6 +24,7 @@ AuthenticationController = require('./Features/Authentication/AuthenticationCont
|
||||||
TagsController = require("./Features/Tags/TagsController")
|
TagsController = require("./Features/Tags/TagsController")
|
||||||
CollaboratorsController = require('./Features/Collaborators/CollaboratorsController')
|
CollaboratorsController = require('./Features/Collaborators/CollaboratorsController')
|
||||||
PersonalInfoController = require('./Features/User/UserController')
|
PersonalInfoController = require('./Features/User/UserController')
|
||||||
|
UserPagesController = require('./Features/User/UserPagesController')
|
||||||
DocumentController = require('./Features/Documents/DocumentController')
|
DocumentController = require('./Features/Documents/DocumentController')
|
||||||
CompileManager = require("./Features/Compile/CompileManager")
|
CompileManager = require("./Features/Compile/CompileManager")
|
||||||
CompileController = require("./Features/Compile/CompileController")
|
CompileController = require("./Features/Compile/CompileController")
|
||||||
|
@ -64,7 +65,7 @@ module.exports = class Router
|
||||||
app.get '/advisor', InfoController.advisor
|
app.get '/advisor', InfoController.advisor
|
||||||
app.get '/dropbox', InfoController.dropbox
|
app.get '/dropbox', InfoController.dropbox
|
||||||
|
|
||||||
app.get '/register', UserController.registerForm
|
app.get '/register', UserPagesController.registerPage
|
||||||
app.post '/register', UserController.apiRegister
|
app.post '/register', UserController.apiRegister
|
||||||
|
|
||||||
SubscriptionRouter.apply(app)
|
SubscriptionRouter.apply(app)
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
should = require('chai').should()
|
||||||
|
SandboxedModule = require('sandboxed-module')
|
||||||
|
assert = require('assert')
|
||||||
|
path = require('path')
|
||||||
|
sinon = require('sinon')
|
||||||
|
modulePath = path.join __dirname, "../../../../app/js/Features/User/UserPagesController"
|
||||||
|
expect = require("chai").expect
|
||||||
|
|
||||||
|
describe "UserPagesController", ->
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
|
||||||
|
@settings = {}
|
||||||
|
@UserPagesController = SandboxedModule.require modulePath, requires:
|
||||||
|
"settings-sharelatex":@settings
|
||||||
|
"logger-sharelatex": log:->
|
||||||
|
|
||||||
|
@req =
|
||||||
|
query:{}
|
||||||
|
session:{}
|
||||||
|
@res = {}
|
||||||
|
|
||||||
|
|
||||||
|
describe "registerPage", ->
|
||||||
|
|
||||||
|
it "should render the register page", (done)->
|
||||||
|
@res.render = (page)=>
|
||||||
|
page.should.equal "user/register"
|
||||||
|
done()
|
||||||
|
@UserPagesController.registerPage @req, @res
|
||||||
|
|
||||||
|
it "should set the redirect", (done)->
|
||||||
|
redirect = "/go/here/please"
|
||||||
|
@req.query.redir = redirect
|
||||||
|
@res.render = (page, opts)=>
|
||||||
|
opts.redir.should.equal redirect
|
||||||
|
done()
|
||||||
|
@UserPagesController.registerPage @req, @res
|
||||||
|
|
||||||
|
it "should set sharedProjectData", (done)->
|
||||||
|
@req.query.project_name = "myProject"
|
||||||
|
@req.query.user_first_name = "user_first_name_here"
|
||||||
|
|
||||||
|
@res.render = (page, opts)=>
|
||||||
|
opts.sharedProjectData.project_name.should.equal "myProject"
|
||||||
|
opts.sharedProjectData.user_first_name.should.equal "user_first_name_here"
|
||||||
|
done()
|
||||||
|
@UserPagesController.registerPage @req, @res
|
||||||
|
|
||||||
|
it "should set newTemplateData", (done)->
|
||||||
|
@req.session.templateData =
|
||||||
|
templateName : "templateName"
|
||||||
|
|
||||||
|
@res.render = (page, opts)=>
|
||||||
|
opts.newTemplateData.templateName.should.equal "templateName"
|
||||||
|
done()
|
||||||
|
@UserPagesController.registerPage @req, @res
|
||||||
|
|
||||||
|
|
||||||
|
it "should not set the newTemplateData if there is nothing in the session", (done)->
|
||||||
|
@res.render = (page, opts)=>
|
||||||
|
assert.equal opts.newTemplateData.templateName, undefined
|
||||||
|
done()
|
||||||
|
@UserPagesController.registerPage @req, @res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue