Skip to content

Commit

Permalink
Use password_reset for registration
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Mar 6, 2024
1 parent d4cf189 commit 1e2bc2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 2 additions & 4 deletions mod/user/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,19 @@ async function post(req, res) {
return res.send(password_reset_verification)
}



// Create new user account
rows = await acl(`
INSERT INTO acl_schema.acl_table (
email,
password,
password_reset,
language,
${process.env.APPROVAL_EXPIRY ? 'expires_on,' : ''}
verificationtoken,
access_log )
SELECT
'${req.body.email}' AS email,
'${password}' AS password,
'${password}' AS password_reset,
'${language}' AS language,
${process.env.APPROVAL_EXPIRY ? `${parseInt((new Date().getTime() + process.env.APPROVAL_EXPIRY * 1000 * 60 * 60 * 24)/1000)} AS expires_on,` : ''}
'${verificationtoken}' AS verificationtoken,
Expand Down
11 changes: 7 additions & 4 deletions mod/user/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = async (req, res) => {

let substitute_params = [user.email, req.params.language || user.language]

user.password_reset && params.push(user.password_reset)
user.password_reset && substitute_params.push(user.password_reset)

// Update user account in ACL with the approval token and remove verification token.
await acl(`
Expand Down Expand Up @@ -110,6 +110,11 @@ module.exports = async (req, res) => {
// One or more administrator have been
if (rows.length > 0) {

// Get the host for approval email.
const host = `${req.headers.origin
|| req.headers.referer && new URL(req.headers.referer).origin
|| 'https://' + (process.env.ALIAS || req.headers.host)}${process.env.DIR}`

// Get array of mail promises.
const mail_promises = rows.map(async row => {

Expand All @@ -118,9 +123,7 @@ module.exports = async (req, res) => {
language: row.language,
to: row.email,
email: user.email,
host: `${req.headers.origin
|| req.headers.referer && new URL(req.headers.referer).origin
|| 'https://' + (process.env.ALIAS || req.headers.host)}${process.env.DIR}`
host
})
})

Expand Down

0 comments on commit 1e2bc2d

Please sign in to comment.