From 434fca887422beb7fc3a36afa2c673052ba76610 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 9 Apr 2014 12:22:57 +0100 Subject: [PATCH] moved login page to new user page controller --- .../Features/User/UserPagesController.coffee | 12 +++++++++--- .../app/coffee/controllers/UserController.coffee | 5 ----- services/web/app/coffee/router.coffee | 2 +- .../coffee/User/UserPagesControllerTests.coffee | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/services/web/app/coffee/Features/User/UserPagesController.coffee b/services/web/app/coffee/Features/User/UserPagesController.coffee index 6bbb9afca6..e5b42ae9b7 100644 --- a/services/web/app/coffee/Features/User/UserPagesController.coffee +++ b/services/web/app/coffee/Features/User/UserPagesController.coffee @@ -1,9 +1,8 @@ module.exports = - - registerPage : (req, res)-> + registerPage : (req, res)-> sharedProjectData = project_name:req.query.project_name user_first_name:req.query.user_first_name @@ -17,4 +16,11 @@ module.exports = redir: req.query.redir sharedProjectData: sharedProjectData newTemplateData: newTemplateData - new_email:req.query.new_email || "" \ No newline at end of file + new_email:req.query.new_email || "" + + loginPage : (req, res)-> + res.render 'user/login', + title: 'Login', + redir: req.query.redir + + diff --git a/services/web/app/coffee/controllers/UserController.coffee b/services/web/app/coffee/controllers/UserController.coffee index 45af440419..3085972be7 100644 --- a/services/web/app/coffee/controllers/UserController.coffee +++ b/services/web/app/coffee/controllers/UserController.coffee @@ -20,11 +20,6 @@ uuid = require("node-uuid") module.exports = - loginForm : (req, res)-> - res.render 'user/login', - title: 'Login', - redir: req.query.redir - apiRegister : (req, res, next = (error) ->)-> logger.log email: req.body.email, "attempted register" redir = Url.parse(req.body.redir or "/project").path diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 3cffb9ca8e..bca4499637 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -48,7 +48,7 @@ module.exports = class Router app.get '/', HomeController.index - app.get '/login', UserController.loginForm + app.get '/login', UserPagesController.loginPage app.post '/login', AuthenticationController.login app.get '/logout', UserController.logout app.get '/restricted', SecurityManager.restricted diff --git a/services/web/test/UnitTests/coffee/User/UserPagesControllerTests.coffee b/services/web/test/UnitTests/coffee/User/UserPagesControllerTests.coffee index 853ff1479b..74cf9a5ced 100644 --- a/services/web/test/UnitTests/coffee/User/UserPagesControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/User/UserPagesControllerTests.coffee @@ -56,7 +56,6 @@ describe "UserPagesController", -> 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 @@ -64,6 +63,18 @@ describe "UserPagesController", -> @UserPagesController.registerPage @req, @res + describe "loginForm", -> + it "should render the login page", (done)-> + @res.render = (page)=> + page.should.equal "user/login" + done() + @UserPagesController.loginPage @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.loginPage @req, @res