From 783b63b09871a1003fe2b92733cd86073b3d0ec6 Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Fri, 5 Feb 2016 09:22:01 +0100 Subject: [PATCH 1/3] Fix #154 - redirect /login to / when already logged in --- server/controllers/routes.coffee | 4 ++-- server/middlewares/authentication.coffee | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/controllers/routes.coffee b/server/controllers/routes.coffee index 08154ba6..dfadda9b 100644 --- a/server/controllers/routes.coffee +++ b/server/controllers/routes.coffee @@ -15,11 +15,11 @@ module.exports = 'routes/reset*': get: index.resetRoutes 'register': - get: auth.registerIndex + get: [utils.isNotAuthenticated, auth.registerIndex] post: [auth.register, utils.authenticate] 'login': - get: auth.loginIndex + get: [utils.isNotAuthenticated, auth.loginIndex] post: utils.authenticate 'login/forgot': post: auth.forgotPassword 'logout': get: [utils.isAuthenticated, auth.logout] diff --git a/server/middlewares/authentication.coffee b/server/middlewares/authentication.coffee index c02f1231..7c01df00 100644 --- a/server/middlewares/authentication.coffee +++ b/server/middlewares/authentication.coffee @@ -38,4 +38,8 @@ module.exports.isAuthenticated = (req, res, next) -> url += "&#{qs.stringify req.query}" if req.query.length res.redirect url - +module.exports.isNotAuthenticated = (req, res, next) -> + if req.isAuthenticated() + res.redirect '/' + else + next() From bc15e292faf6f823d2eba2caa165395d488c31d8 Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Fri, 5 Feb 2016 09:41:56 +0100 Subject: [PATCH 2/3] Fix #199 - add warning when JS or cookies are disabled --- server/views/index.jade | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/views/index.jade b/server/views/index.jade index 8ca86ef9..3cb9491b 100644 --- a/server/views/index.jade +++ b/server/views/index.jade @@ -7,6 +7,13 @@ block title block content main(role='application') + noscript + section.popup + header + a(title='Cozy Website', href='https://cozy.io') + .container + h1 Sorry + p.help Cozy needs JavaScript and cookies to work but it looks like you have disabled one of them. block js script(src="/scripts/vendor.js") From c81b03a1bda04a732447c99e94dbd4a6d11572f2 Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Fri, 5 Feb 2016 10:44:10 +0100 Subject: [PATCH 3/3] Localize noscript message --- server/locales/en.json | 4 ++++ server/views/index.jade | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/locales/en.json b/server/locales/en.json index 035cf11c..b9b9472a 100644 --- a/server/locales/en.json +++ b/server/locales/en.json @@ -1,4 +1,8 @@ { + "index title": "Cozy - Your Private Personal Cloud", + "index description": "Cozy is an app-based personal cloud you can host at home. It allows you to own and connect your data. It turns a low-cost piece of hardware like a Raspberry Pi 2 or an online VPS into a powerful app platform. It comes with common applications like a contacts manager, calendar, webmail and filebox.", + "index noscript title": "Sorry", + "index noscript message": "Cozy needs JavaScript and cookies to work but it looks like you have disabled one of them.", "error title": "Oops, an error has occurred", "error headline": "It seems that something went wrong.", "error reinsurance": "Don't worry, it's probably not that bad!", diff --git a/server/views/index.jade b/server/views/index.jade index 3cb9491b..bc24d238 100644 --- a/server/views/index.jade +++ b/server/views/index.jade @@ -1,8 +1,8 @@ extends layouts/_base block title - title Cozy - Your Private Personal Cloud - meta(name="description", content="Cozy is an app-based personal cloud you can host at home. It allows you to own and connect your data. It turns a low-cost piece of hardware like a Raspberry Pi 2 or an online VPS into a powerful app platform. It comes with common applications like a contacts manager, calendar, webmail and filebox.") + title= t('index title') + meta(name="description", content=t('index description')) block content @@ -12,8 +12,8 @@ block content header a(title='Cozy Website', href='https://cozy.io') .container - h1 Sorry - p.help Cozy needs JavaScript and cookies to work but it looks like you have disabled one of them. + h1= t('index noscript title') + p.help= t('index noscript message') block js script(src="/scripts/vendor.js")