Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions controllers/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ async function register(req, res) {
username
});
}

// Rudimentary email format check
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // basically: "string" + "@" + "string" + "." + "string"
if (!emailRegex.test(email)) {
return res.render('pages/register', {
error: 'Please enter a valid email address',
email,
username
});
}

// Check if email already exists
const [emailCheck] = await connection.query(
'SELECT * FROM users WHERE email = ?',
Expand Down
32 changes: 32 additions & 0 deletions routes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,38 @@ router.post('/login', controller.login);
*/
router.get('/logout', controller.logout);

/**
* @swagger
* /agreements/tos:
* get:
* summary: Returns the Terms of Service as plain text
* description: Serves the Terms of Service agreement in plain text format.
* produces:
* - text/plain
* responses:
* 200:
* description: The Terms of Service text file
*/
router.get('/agreements/tos', (req, res) => {
res.sendFile(path.join(__dirname, '../public/agreements/tos.txt'));
});

/**
* @swagger
* /agreements/eula:
* get:
* summary: Returns the End User License Agreement as plain text
* description: Serves the End User License Agreement (EULA) in plain text format.
* produces:
* - text/plain
* responses:
* 200:
* description: The EULA text file
*/
router.get('/agreements/eula', (req, res) => {
res.sendFile(path.join(__dirname, '../public/agreements/eula.txt'));
});

/**
* @swagger
* /updateUsername:
Expand Down
2 changes: 2 additions & 0 deletions views/partials/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
</div>
<p>SYSTEM STATUS: <span class="text-terminal-green">ONLINE</span></p>
<p>VERSION 0.0.1</p>
<a href="/agreements/tos" class="hover:underline text-terminal-green" target="_blank">Terms of Service</a>
<a href="/agreements/eula" class="hover:underline text-terminal-green" target="_blank">EULA</a>
</div>
</div>
</footer>
Expand Down