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/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/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() diff --git a/server/views/index.jade b/server/views/index.jade index 8ca86ef9..bc24d238 100644 --- a/server/views/index.jade +++ b/server/views/index.jade @@ -1,12 +1,19 @@ 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 main(role='application') + noscript + section.popup + header + a(title='Cozy Website', href='https://cozy.io') + .container + h1= t('index noscript title') + p.help= t('index noscript message') block js script(src="/scripts/vendor.js")