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 @@ <% }) %> <% } %> -
+ + + +