From 94018f8bdc406735431b19af9e9aafc41cb29047 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:12:53 +0000 Subject: [PATCH 1/6] Initial plan From 3edd24a2c11492ba3f08f893e18754adff1b1dce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:15:58 +0000 Subject: [PATCH 2/6] Improve error messaging for login/register process - Add user-friendly error messages for duplicate username/email during registration - Distinguish between 2FA notification denied vs timeout - Add loading banner during 2FA authentication wait Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com> --- create-a-container/routers/login.js | 11 +++++++++-- create-a-container/routers/register.js | 15 ++++++++++++++- create-a-container/views/login.ejs | 22 ++++++++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/create-a-container/routers/login.js b/create-a-container/routers/login.js index 955964e9..9e919c24 100644 --- a/create-a-container/routers/login.js +++ b/create-a-container/routers/login.js @@ -74,8 +74,15 @@ router.post('/', async (req, res) => { return res.redirect('/login'); } - if (result.action?.toUpperCase() !== 'APPROVE') { - req.flash('error', 'Authentication request was denied'); + if (result.action !== 'approve') { + // Distinguish between different failure scenarios + if (result.action === 'reject') { + req.flash('error', 'Second factor push notification was denied.'); + } else if (result.action === 'timeout') { + req.flash('error', 'Second factor push notification timed out. Please try again.'); + } else { + req.flash('error', `Second factor push notification failed: ${result.action}. Please contact support.`); + } return res.redirect('/login'); } } catch (error) { diff --git a/create-a-container/routers/register.js b/create-a-container/routers/register.js index 67c93b5e..0fa840ab 100644 --- a/create-a-container/routers/register.js +++ b/create-a-container/routers/register.js @@ -30,7 +30,20 @@ router.post('/', async (req, res) => { return res.redirect('/login'); } catch (err) { console.error('Registration error:', err); - req.flash('error', 'Registration failed: ' + err.message); + + // Handle Sequelize unique constraint errors with user-friendly messages + if (err.name === 'SequelizeUniqueConstraintError') { + const field = err.errors[0]?.path; + if (field === 'uid') { + req.flash('error', 'This username is already registered. Please choose a different username or login with your existing account.'); + } else if (field === 'mail') { + req.flash('error', 'This email address is already registered. Please use a different email or login with your existing account.'); + } else { + req.flash('error', 'A user with these details is already registered. Please login with your existing account.'); + } + } else { + req.flash('error', 'Registration failed: ' + err.message); + } return res.redirect('/register'); } }); diff --git a/create-a-container/views/login.ejs b/create-a-container/views/login.ejs index 284484c0..9679e03f 100644 --- a/create-a-container/views/login.ejs +++ b/create-a-container/views/login.ejs @@ -27,7 +27,7 @@ <% }) %> <% } %> -
+ @@ -36,8 +36,15 @@ - +
+ + + +
Forgot your password? @@ -51,5 +58,16 @@ © 2025 Medical Informatics Engineering
+ + \ No newline at end of file From c3c463d25fdfb3a2880f6cd3f6e2deda3fee213b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:23:08 +0000 Subject: [PATCH 3/6] Address code review feedback: Add null safety checks and DOMContentLoaded wrapper Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com> --- create-a-container/routers/register.js | 2 +- create-a-container/views/login.ejs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/create-a-container/routers/register.js b/create-a-container/routers/register.js index 0fa840ab..c663e139 100644 --- a/create-a-container/routers/register.js +++ b/create-a-container/routers/register.js @@ -32,7 +32,7 @@ router.post('/', async (req, res) => { console.error('Registration error:', err); // Handle Sequelize unique constraint errors with user-friendly messages - if (err.name === 'SequelizeUniqueConstraintError') { + if (err.name === 'SequelizeUniqueConstraintError' && err.errors && err.errors.length > 0) { const field = err.errors[0]?.path; if (field === 'uid') { req.flash('error', 'This username is already registered. Please choose a different username or login with your existing account.'); diff --git a/create-a-container/views/login.ejs b/create-a-container/views/login.ejs index 9679e03f..7841ed0c 100644 --- a/create-a-container/views/login.ejs +++ b/create-a-container/views/login.ejs @@ -60,13 +60,16 @@ From 11a8baed6625f988d9db4f9d8499147c156a67f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 19:11:55 +0000 Subject: [PATCH 4/6] Move inline styles to CSS classes in style.css - Created reusable alert classes (alert, alert-success, alert-error, alert-info) - Replaced all inline styles in login.ejs and register.ejs with CSS classes - Loading banner now uses alert alert-info classes with only display:none inline - Improves maintainability and consistency across the application Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com> --- create-a-container/public/style.css | 36 +++++++++++++++++++++++++++ create-a-container/views/login.ejs | 8 +++--- create-a-container/views/register.ejs | 4 +-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/create-a-container/public/style.css b/create-a-container/public/style.css index 52201bd5..f88134b3 100644 --- a/create-a-container/public/style.css +++ b/create-a-container/public/style.css @@ -368,3 +368,39 @@ main { .navbar { border-bottom: 2px solid #1a252f; } + +/* Alert/Message boxes */ +.alert { + margin-bottom: 1rem; + padding: 0.75rem; + border: 1px solid transparent; + border-radius: 4px; +} + +.alert-success { + color: #155724; + background-color: #d4edda; + border-color: #c3e6cb; +} + +.alert-error { + color: #721c24; + background-color: #f8d7da; + border-color: #f5c6cb; +} + +.alert-info { + color: #004085; + background-color: #cce5ff; + border-color: #b8daff; +} + +.alert-info strong { + display: block; + margin-bottom: 0.5rem; +} + +.alert-info p { + margin: 0.5rem 0 0 0; + font-size: 0.9em; +} diff --git a/create-a-container/views/login.ejs b/create-a-container/views/login.ejs index 7841ed0c..097ff5ca 100644 --- a/create-a-container/views/login.ejs +++ b/create-a-container/views/login.ejs @@ -13,7 +13,7 @@ <% if (successMessages && successMessages.length > 0) { %> <% successMessages.forEach(function(message) { %> -
+
<%= message %>
<% }) %> @@ -21,7 +21,7 @@ <% if (errorMessages && errorMessages.length > 0) { %> <% errorMessages.forEach(function(message) { %> -
+
<%- message %>
<% }) %> @@ -40,9 +40,9 @@ -