Commit bdead1f1 authored by Wolfgang Knopki's avatar Wolfgang Knopki
Browse files

Merge branch 'MLAB-566' into 'master'

Mlab 566

See merge request !116
parents 09696cce 4253099f
Pipeline #4844 passed with stage
in 21 seconds
...@@ -4,59 +4,34 @@ var env = process.env.NODE_ENV || 'testing' ...@@ -4,59 +4,34 @@ var env = process.env.NODE_ENV || 'testing'
const config = require('./config')[env] const config = require('./config')[env]
// ==== USER ACOOUNT DB CONNECTION ==== // ==== USER ACOOUNT DB CONNECTION ====
var userConnection = mysql.createConnection({ const userConnection = mysql.createPool({
host: config.database.host, host: config.database.host,
user: config.database.user, user: config.database.user,
password: config.database.password, password: config.database.password,
port: config.database.port, port: config.database.port,
database: config.database.dbUser, database: config.database.dbUser,
multipleStatements: true waitForConnections: true,
}) connectionLimit: 10,
queueLimit: 0
});
userConnection.connect(function(err) {
if (err) throw err
})
userConnection.query('USE '+config.database.dbUser) userConnection.query('USE '+config.database.dbUser)
// ALTERNATIVE approach: close db connection manually after every query
/*
var dbconn = function dbconn(query, values, next) {
var connection = mysql.createConnection({
host: config.database.host,
user: config.database.user,
password: config.database.password,
port: config.database.port,
database: config.database.db
})
connection.connect(function(err) {
if (err) throw err;
})
connection.query(query, values, function(err) {
connection.end(); // close the connection
if (err) {
throw err;
}
// Execute the callback
next.apply(this, arguments);
});
}
*/
// ==== PROJECT DB CONNECTION ==== // ==== PROJECT DB CONNECTION ====
var projectConnection = mysql.createConnection({ const projectConnection = mysql.createPool({
host: config.database.host_project, host: config.database.host_project,
user: config.database.user, user: config.database.user,
password: config.database.password, password: config.database.password,
port: config.database.port, port: config.database.port,
database: config.database.dbProject database: config.database.dbProject,
}) waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
projectConnection.connect(function(err) {
if (err) throw err
})
projectConnection.query('USE '+config.database.dbProject) projectConnection.query('USE '+config.database.dbProject)
var connection = { const connection = {
user: userConnection, user: userConnection,
project: projectConnection project: projectConnection
} }
......
...@@ -237,9 +237,11 @@ export = function (app:any, config:any, lang:string) { ...@@ -237,9 +237,11 @@ export = function (app:any, config:any, lang:string) {
// encrypt password // encrypt password
bcrypt.genSalt(saltRounds, function(err, salt) { bcrypt.genSalt(saltRounds, function(err, salt) {
bcrypt.hash(newPwd, salt, async function(err:any, hash) { bcrypt.hash(newPwd, salt, async function(err:any, hash) {
var credentialData = { let credentialData = {
password: hash, password: hash,
user_id: user.user_id user_id: user.user_id,
resetPasswordToken: null,
resetPasswordExpires: null
} }
// update password // update password
let result = await methods.updateCredential(credentialData) let result = await methods.updateCredential(credentialData)
...@@ -248,7 +250,7 @@ export = function (app:any, config:any, lang:string) { ...@@ -248,7 +250,7 @@ export = function (app:any, config:any, lang:string) {
res.flash('error', "Datenbankfehler: Passwort kann nicht geändert werden.") res.flash('error', "Datenbankfehler: Passwort kann nicht geändert werden.")
} else { } else {
res.flash('success', "Passwort aktualisiert!") res.flash('success', "Passwort aktualisiert!")
// send notifiaction email // send notification email
mailer.options.to = user.email mailer.options.to = user.email
mailer.options.subject = constants.updatePasswordMailSubject mailer.options.subject = constants.updatePasswordMailSubject
mailer.options.html = constants.updatePasswordMailContent+'<div>'+constants.mailSignature+'</div>' mailer.options.html = constants.updatePasswordMailContent+'<div>'+constants.mailSignature+'</div>'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment