From 4bcf8dd8127a6b8d63d8279881af9b13c98aa732 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 5 May 2025 14:21:30 -0700 Subject: [PATCH 1/7] feature/started work on layout.ejs --- app.js | 26 +++++++++++++------------- src/views/index.ejs | 15 +-------------- src/views/layout.ejs | 13 +++++++++++++ src/views/signup.ejs | 5 ----- 4 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 src/views/layout.ejs diff --git a/app.js b/app.js index 2fc8319..c091745 100644 --- a/app.js +++ b/app.js @@ -18,23 +18,23 @@ app.use(session({ })); /*** Database ***/ -const { connectMongo, getCollection } = require("./src/database/connection"); +// const { connectMongo, getCollection } = require("./src/database/connection"); -let users; -async function initDatabase() { - const mongoURI = process.env.mongoURI || "mongodb://localhost:27017/"; - const database = process.env.database || "knoldus"; // Database name +// let users; +// async function initDatabase() { +// const mongoURI = process.env.mongoURI || "mongodb://localhost:27017/"; +// const database = process.env.database || "knoldus"; // Database name - const db = await connectMongo(mongoURI, database); +// const db = await connectMongo(mongoURI, database); - // For any collection, init here - users = await getCollection(db, "users"); -} +// // For any collection, init here +// users = await getCollection(db, "users"); +// } -initDatabase().then(() => { - require("./src/auth/authentication")(app, users); -}); +// initDatabase().then(() => { +// require("./src/auth/authentication")(app, users); +// }); /* ROUTINGS @@ -42,7 +42,7 @@ ROUTINGS app.get('/', (req, res) => { if (!req.session.errMessage) req.session.errMessage = ""; - res.render('index'); + res.render('layout'); }); app.get('/landing', (req, res) => { diff --git a/src/views/index.ejs b/src/views/index.ejs index 04287c1..20ea401 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -1,14 +1 @@ - - - - - - - Document - - - - The Index page - - - +

The index page

\ No newline at end of file diff --git a/src/views/layout.ejs b/src/views/layout.ejs new file mode 100644 index 0000000..92b7356 --- /dev/null +++ b/src/views/layout.ejs @@ -0,0 +1,13 @@ + + + + + + + + <%= title %> + + + <%- include(filename, locals) %> + + \ No newline at end of file diff --git a/src/views/signup.ejs b/src/views/signup.ejs index c471971..fc28f8a 100644 --- a/src/views/signup.ejs +++ b/src/views/signup.ejs @@ -6,11 +6,6 @@ Signup - - - From f6640b23cfd999999fe3b14c1a4d2772c3b5098c Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 5 May 2025 17:07:51 -0700 Subject: [PATCH 2/7] feature/some progress made on layouts --- src/views/aboutUs.ejs | 99 +++++++++---------- src/views/assets.ejs | 10 +- src/views/home.ejs | 10 +- src/views/index.ejs | 10 +- src/views/login.ejs | 14 +-- src/views/more.ejs | 9 +- .../{layout.ejs => partials/fileHeader.ejs} | 6 +- src/views/plans.ejs | 10 +- 8 files changed, 54 insertions(+), 114 deletions(-) rename src/views/{layout.ejs => partials/fileHeader.ejs} (80%) diff --git a/src/views/aboutUs.ejs b/src/views/aboutUs.ejs index e5979bd..aa69b97 100644 --- a/src/views/aboutUs.ejs +++ b/src/views/aboutUs.ejs @@ -1,56 +1,49 @@ - - - RCalculator - - - - - <%- include("./partials/headerStart") %> -
-
-
-

About RCalculator

-

Welcome to RCalculator, your partner in building a secure and fulfilling financial future.

-
+<%- include("./partials/fileHeader", {title: "RCalculator"}) %> -
-

Our Mission

-

- Our mission is to empower you with the tools and insights needed to take control of your long-term financial goals. -

-
-

- We believe that planning for your desired future, especially retirement, shouldn't be daunting. It doesn't matter what your current age or career status is – starting now is what counts. -

-

- At RCalculator, we help you trace a personalized plan that suits your unique aspirations. We provide clear, actionable advice and projections to guide you on how to get there, whether you're just starting your career, mid-way through, or nearing retirement. -

-

- Let us help you navigate the path to financial independence and achieve the retirement lifestyle you envision. -

-
-
- -
-
-
-
- - - - - - \ No newline at end of file +
+

Our Mission

+

+ Our mission is to empower you with the tools and insights needed to take control of your long-term financial goals. +

+
+

+ We believe that planning for your desired future, especially retirement, shouldn't be daunting. It doesn't matter what your current age or career status is – starting now is what counts. +

+

+ At RCalculator, we help you trace a personalized plan that suits your unique aspirations. We provide clear, actionable advice and projections to guide you on how to get there, whether you're just starting your career, mid-way through, or nearing retirement. +

+

+ Let us help you navigate the path to financial independence and achieve the retirement lifestyle you envision. +

+
+
+ + + +
+ +
+ + + + \ No newline at end of file diff --git a/src/views/assets.ejs b/src/views/assets.ejs index acaa431..db02619 100644 --- a/src/views/assets.ejs +++ b/src/views/assets.ejs @@ -1,11 +1,5 @@ - - - - - - - Document - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %> + <%- include("./partials/header") %>
diff --git a/src/views/home.ejs b/src/views/home.ejs index 3bb7034..40c82dd 100644 --- a/src/views/home.ejs +++ b/src/views/home.ejs @@ -1,12 +1,4 @@ - - - - - - - - Document - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %> <%- include("./partials/header") %> diff --git a/src/views/index.ejs b/src/views/index.ejs index 975b566..21b69f8 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -1,12 +1,4 @@ - - - - - - - - Document - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %> The Index Page diff --git a/src/views/login.ejs b/src/views/login.ejs index d4b1b31..02dbd6c 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -1,16 +1,4 @@ - - - - - - - - Login Page - - - - - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %>
diff --git a/src/views/more.ejs b/src/views/more.ejs index 7884eaf..50414f0 100644 --- a/src/views/more.ejs +++ b/src/views/more.ejs @@ -1,11 +1,4 @@ - - - - - - - Document - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %> <%- include("./partials/header") %> diff --git a/src/views/layout.ejs b/src/views/partials/fileHeader.ejs similarity index 80% rename from src/views/layout.ejs rename to src/views/partials/fileHeader.ejs index 92b7356..069c5d8 100644 --- a/src/views/layout.ejs +++ b/src/views/partials/fileHeader.ejs @@ -6,8 +6,4 @@ <%= title %> - - - <%- include(filename, locals) %> - - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/plans.ejs b/src/views/plans.ejs index 9645deb..c2c0337 100644 --- a/src/views/plans.ejs +++ b/src/views/plans.ejs @@ -1,12 +1,4 @@ - - - - - - - - Document - +<%- include("./partials/fileHeader", {title: "RCalculator"}) %> <%- include("./partials/header") %> From c8bf2e49abdfc0c27641e90e9de42817da344f12 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 5 May 2025 21:12:52 -0700 Subject: [PATCH 3/7] feature/completed most of ejs implementation into other pages --- src/views/aboutUs.ejs | 81 +++++++++++++------------------ src/views/assets.ejs | 22 +++------ src/views/landing.ejs | 60 +++++++++-------------- src/views/partials/fileHeader.ejs | 3 +- src/views/partials/footer.ejs | 10 ++++ src/views/partials/navBar.ejs | 3 +- 6 files changed, 78 insertions(+), 101 deletions(-) create mode 100644 src/views/partials/footer.ejs diff --git a/src/views/aboutUs.ejs b/src/views/aboutUs.ejs index aa69b97..1977166 100644 --- a/src/views/aboutUs.ejs +++ b/src/views/aboutUs.ejs @@ -1,49 +1,38 @@ <%- include("./partials/fileHeader", {title: "RCalculator"}) %> - - <%- include("./partials/headerStart") %> -
-
-
-

About RCalculator

-

Welcome to RCalculator, your partner in building a secure and fulfilling financial future.

-
- -
-

Our Mission

-

- Our mission is to empower you with the tools and insights needed to take control of your long-term financial goals. -

-
-

- We believe that planning for your desired future, especially retirement, shouldn't be daunting. It doesn't matter what your current age or career status is – starting now is what counts. -

-

- At RCalculator, we help you trace a personalized plan that suits your unique aspirations. We provide clear, actionable advice and projections to guide you on how to get there, whether you're just starting your career, mid-way through, or nearing retirement. -

-

- Let us help you navigate the path to financial independence and achieve the retirement lifestyle you envision. -

-
-
- -
-
-
-
- - - - \ No newline at end of file + +
+

Our Mission

+

+ Our mission is to empower you with the tools and insights needed to take control of your long-term financial goals. +

+
+

+ We believe that planning for your desired future, especially retirement, shouldn't be daunting. It doesn't matter what your current age or career status is – starting now is what counts. +

+

+ At RCalculator, we help you trace a personalized plan that suits your unique aspirations. We provide clear, actionable advice and projections to guide you on how to get there, whether you're just starting your career, mid-way through, or nearing retirement. +

+

+ Let us help you navigate the path to financial independence and achieve the retirement lifestyle you envision. +

+
+
+ + +
+<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/assets.ejs b/src/views/assets.ejs index db02619..58cd89d 100644 --- a/src/views/assets.ejs +++ b/src/views/assets.ejs @@ -1,17 +1,9 @@ <%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/header") %> - - <%- include("./partials/header") %> -
- The Assets Page -
-
- - <%- include("./partials/navBar") %> -
- - +
+ The Assets Page +
+ +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/landing.ejs b/src/views/landing.ejs index 325ad13..dfd408a 100644 --- a/src/views/landing.ejs +++ b/src/views/landing.ejs @@ -1,38 +1,24 @@ - - - RCalculator - - - - - <%- include("./partials/headerStart") %> -
-
-
-

Plan now, live better.

-

Planning your retirement is a crucial step towards financial security and a happy future.

- -
-
-
-
-
-
-

© 2025 RCalculator. All rights reserved.

-
+<%- include("./partials/fileHeader") %> +<%- include("./partials/headerStart") %> + +
+
+
+

Plan now, live better.

+

Planning your retirement is a crucial step towards financial security and a happy future.

+ -
- - - - + + + + +<%- include("./partials/footer") %> diff --git a/src/views/partials/fileHeader.ejs b/src/views/partials/fileHeader.ejs index 069c5d8..8218bb4 100644 --- a/src/views/partials/fileHeader.ejs +++ b/src/views/partials/fileHeader.ejs @@ -6,4 +6,5 @@ <%= title %> - \ No newline at end of file + + \ No newline at end of file diff --git a/src/views/partials/footer.ejs b/src/views/partials/footer.ejs new file mode 100644 index 0000000..8f457f3 --- /dev/null +++ b/src/views/partials/footer.ejs @@ -0,0 +1,10 @@ + +
+ +
+ + \ No newline at end of file diff --git a/src/views/partials/navBar.ejs b/src/views/partials/navBar.ejs index edc5772..6b12cf0 100644 --- a/src/views/partials/navBar.ejs +++ b/src/views/partials/navBar.ejs @@ -26,5 +26,4 @@ More - - + \ No newline at end of file From 54566f05b749bad66f2767978fc6d70c4c4ed218 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 5 May 2025 21:56:47 -0700 Subject: [PATCH 4/7] feature/fully implemented ejs inclusion to main files --- src/views/aboutUs.ejs | 7 ++++--- src/views/assets.ejs | 2 +- src/views/home.ejs | 24 ++++++++---------------- src/views/index.ejs | 18 ++++++------------ src/views/landing.ejs | 2 +- src/views/login.ejs | 11 +++++------ src/views/more.ejs | 24 ++++++++---------------- src/views/partials/fileHeader.ejs | 2 +- src/views/partials/headerStart.ejs | 2 +- src/views/plans.ejs | 23 +++++++---------------- src/views/signup.ejs | 20 ++++++-------------- src/views/template.ejs | 9 +++++++++ 12 files changed, 57 insertions(+), 87 deletions(-) create mode 100644 src/views/template.ejs diff --git a/src/views/aboutUs.ejs b/src/views/aboutUs.ejs index 1977166..32ded54 100644 --- a/src/views/aboutUs.ejs +++ b/src/views/aboutUs.ejs @@ -1,6 +1,6 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> - +<%- include("./partials/fileHeader") %> <%- include("./partials/headerStart") %> +
@@ -26,7 +26,7 @@
+ <%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/assets.ejs b/src/views/assets.ejs index 58cd89d..a926f36 100644 --- a/src/views/assets.ejs +++ b/src/views/assets.ejs @@ -1,4 +1,4 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/fileHeader") %> <%- include("./partials/header") %>
diff --git a/src/views/home.ejs b/src/views/home.ejs index e8219bc..840dc07 100644 --- a/src/views/home.ejs +++ b/src/views/home.ejs @@ -1,18 +1,10 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> - -
- <%- include("./partials/header") %> - Welcome: <%= user.email %> - The Dashboard Page -
-
-
-
-

© 2025 RCalculator. All rights reserved.

-
-
-
- +
+ Welcome: <%= user.email %> + The Dashboard Page +
- +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/index.ejs b/src/views/index.ejs index 21b69f8..935b4a0 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -1,15 +1,9 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> - +
The Index Page -
-
-
-

© 2025 RCalculator. All rights reserved.

-
-
- <%- include("./partials/navBar") %> -
- +
- +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/landing.ejs b/src/views/landing.ejs index dfd408a..d7a24d1 100644 --- a/src/views/landing.ejs +++ b/src/views/landing.ejs @@ -7,7 +7,7 @@

Plan now, live better.

Planning your retirement is a crucial step towards financial security and a happy future.

- + Get started -
+
+

Login

@@ -39,7 +39,6 @@
- - +
- +<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/more.ejs b/src/views/more.ejs index 50414f0..59e3acf 100644 --- a/src/views/more.ejs +++ b/src/views/more.ejs @@ -1,18 +1,10 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> - - <%- include("./partials/header") %> -
- The More Page -
-
-
-
-

© 2025 RCalculator. All rights reserved.

-
-
- <%- include("./partials/navBar") %> -
- +
+ The More Page +
- +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> + \ No newline at end of file diff --git a/src/views/partials/fileHeader.ejs b/src/views/partials/fileHeader.ejs index 8218bb4..35b60ed 100644 --- a/src/views/partials/fileHeader.ejs +++ b/src/views/partials/fileHeader.ejs @@ -5,6 +5,6 @@ - <%= title %> + RCalculator \ No newline at end of file diff --git a/src/views/partials/headerStart.ejs b/src/views/partials/headerStart.ejs index 5e07c61..b2b4f4b 100644 --- a/src/views/partials/headerStart.ejs +++ b/src/views/partials/headerStart.ejs @@ -20,7 +20,7 @@
Home
  • - About Us + Login
  • Contact us diff --git a/src/views/plans.ejs b/src/views/plans.ejs index c2c0337..7f6e699 100644 --- a/src/views/plans.ejs +++ b/src/views/plans.ejs @@ -1,18 +1,9 @@ -<%- include("./partials/fileHeader", {title: "RCalculator"}) %> +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> - - <%- include("./partials/header") %> -
    - The Plans Page -
    -
    -
    -
    -

    © 2025 RCalculator. All rights reserved.

    -
    -
    - <%- include("./partials/navBar") %> -
    - +
    + The Plans Page +
    - +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> diff --git a/src/views/signup.ejs b/src/views/signup.ejs index 7ea5239..7411268 100644 --- a/src/views/signup.ejs +++ b/src/views/signup.ejs @@ -1,15 +1,8 @@ - - +<%- include("./partials/fileHeader") %> +<%- include("./partials/headerStart") %> - - - - - Signup - - - -
    +
    +

    Signup

    @@ -42,7 +35,6 @@
    - - +
    - +<%- include("./partials/footer") %> \ No newline at end of file diff --git a/src/views/template.ejs b/src/views/template.ejs new file mode 100644 index 0000000..868ca17 --- /dev/null +++ b/src/views/template.ejs @@ -0,0 +1,9 @@ +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> + +
    + +
    + +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> \ No newline at end of file From 1e32ccfa177c3131407fe02284b0adf0393050e9 Mon Sep 17 00:00:00 2001 From: nicoagostini Date: Tue, 6 May 2025 02:07:58 -0700 Subject: [PATCH 5/7] feature/questionnaire page create + saving to MongoDb --- app.js | 6 +- src/auth/authentication.js | 7 ++- src/auth/middleware.js | 1 + src/router/user.js | 75 ++++++++++++++++++++++++- src/views/home.ejs | 4 ++ src/views/questionnaire.ejs | 108 ++++++++++++++++++++++++++++++++++++ 6 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 src/views/questionnaire.ejs diff --git a/app.js b/app.js index 958ede4..677c2fb 100644 --- a/app.js +++ b/app.js @@ -3,8 +3,10 @@ const MongoStore = require("connect-mongo"); const session = require("express-session"); const express = require('express'); const path = require('path'); +const joi = require('joi'); require('dotenv').config(); + const app = express(); const port = process.env.PORT || 3000; @@ -18,7 +20,7 @@ app.use(session({ store: MongoStore.create({ mongoUrl: `${mongoURI}${database}`, crypto: { secret: secret } }), resave: true, saveUninitialized: false, - cookie: { maxAge: 60000 }, + cookie: { maxAge: 3600000 }, })); app.set('view engine', 'ejs'); @@ -79,7 +81,7 @@ initDatabase().then(() => { // Import middleware & apply to user routes const middleware = require("./src/auth/middleware")(users); - app.use(require('./src/router/user')(middleware)); + app.use(require('./src/router/user')(middleware, users)); // 404 handler app.get('/*splat', (req, res) => { diff --git a/src/auth/authentication.js b/src/auth/authentication.js index 559b7ca..e680fb3 100644 --- a/src/auth/authentication.js +++ b/src/auth/authentication.js @@ -3,6 +3,9 @@ const bcrypt = require('bcrypt'); const joi = require("joi"); const salt = 12; +const middleware = require("./middleware"); + + module.exports = (users) => { const router = require("express").Router(); @@ -13,6 +16,7 @@ module.exports = (users) => { }); router.post("/login", async (req, res) => { + const credentialSchema = joi.object({ email: joi.string().email().required(), password: joi.string().max(20).required(), @@ -39,9 +43,10 @@ module.exports = (users) => { return res.redirect("/login"); } + console.log("User logged in successfully"); + console.log("User email: " + req.body.email); req.session.authenticated = true; req.session.email = req.body.email; - req.session.errMessage = ""; res.redirect("/home"); return res.status(status.Ok); diff --git a/src/auth/middleware.js b/src/auth/middleware.js index 7ca7afe..8eeaff2 100644 --- a/src/auth/middleware.js +++ b/src/auth/middleware.js @@ -1,4 +1,5 @@ const status = require("../util/statuses"); +const session = require("express-session"); /** * createMiddleware returns a middleware function for express. diff --git a/src/router/user.js b/src/router/user.js index 3187328..21ae127 100644 --- a/src/router/user.js +++ b/src/router/user.js @@ -1,6 +1,7 @@ const status = require("../util/statuses"); +const joi = require("joi"); -module.exports = (middleware) => { +module.exports = (middleware, users) => { const router = require("express").Router(); router.use(middleware); @@ -35,6 +36,78 @@ module.exports = (middleware) => { return res.status(status.Ok); }); + router.get('/questionnaire', (req, res) => { + const errMessage = req.session.errMessage; + req.session.errMessage = ""; + res.render('questionnaire', { user: req.user, errMessage: errMessage }); + }); + + router.post('/questionnaire', (req, res) => { + console.log("Questionnaire POST body:", req.body); + + const questionnaireSchema = joi.object({ + dob: joi.date().required(), + education: joi.string().valid('primary', 'secondary', 'tertiary', 'postgraduate').required(), + maritalStatus: joi.string().valid('single', 'married', 'divorced', 'widowed').required(), + income: joi.number().min(0).required(), + expenses: joi.number().min(0).required(), + assets: joi.number().min(0).required(), + liabilities: joi.number().min(0).required(), + retirementAge: joi.number().min(18).max(120).required(), + retirementExpenses: joi.number().min(0).required(), + retirementAssets: joi.number().min(0).required(), + retirementLiabilities: joi.number().min(0).required(), + }); + + const validationOptions = { convert: true, abortEarly: false }; + const { error, value } = questionnaireSchema.validate(req.body, validationOptions); + + if (error) { + console.error("Questionnaire validation error:", error.details); + req.session.errMessage = "Invalid input: " + error.details.map(d => d.message.replace(/"/g, '')).join(', '); + res.status(status.BadRequest).redirect("/questionnaire"); + return; + } + + users.updateOne( + { email: req.session.email }, + { + $set: { + financialData: true, + dob: value.dob, + education: value.education, + maritalStatus: value.maritalStatus, + income: value.income, + expenses: value.expenses, + assets: value.assets, + liabilities: value.liabilities, + retirementAge: value.retirementAge, + retirementExpenses: value.retirementExpenses, + retirementAssets: value.retirementAssets, + retirementLiabilities: value.retirementLiabilities, + } + } + ).then((result) => { + if (result.matchedCount === 0) { + console.log(`User not found during questionnaire update: ${req.session.email}`); + req.session.errMessage = "User session invalid. Please log in again."; + res.status(status.NotFound).redirect("/login"); + return; + } + if (result.modifiedCount === 0 && result.matchedCount === 1) { + console.log(`User questionnaire data unchanged (already up-to-date): ${req.session.email}`); + } + + req.session.errMessage = ""; + res.status(status.Ok).redirect("/home"); + + }).catch(err => { + console.error("Error updating questionnaire in database:", err); + req.session.errMessage = "An error occurred while saving your information. Please try again."; + res.status(status.InternalServerError).redirect("/questionnaire"); + }); + }); + router.get('/logout', (req, res) => { req.session.destroy(); return res.redirect('/login'); diff --git a/src/views/home.ejs b/src/views/home.ejs index bd514d7..eaafeb2 100644 --- a/src/views/home.ejs +++ b/src/views/home.ejs @@ -13,6 +13,10 @@ <%- include("./partials/header") %> Welcome: <%= user.email %> The Dashboard Page + <% if(user.authenticated) { %> + <%= user.email %> + <%= user.errMessage %> + <% } %>