thisconn.query('INSERT INTO user SET ?',data.profile,function(err:any,results:any,fields:any){
thisconn.query('INSERT INTO user SET ?',data.profile,function(err:any,results:any,fields:any){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
});
})
}
letnewUserId:number=results.insertId
constnewUserId:number=results.insertId
// set password
varcredentialData:any={
constcredentialData:any={
user_id:newUserId,
password:data.password
}
thisconn.query('INSERT INTO credential SET ?',credentialData,function(err:any,results:any,fields:any){
thisconn.query('INSERT INTO credential SET ?',credentialData,function(err:any,results:any,fields:any){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
});
})
}
// set default user-project-role
varprojectRoleData:any={
project_id:1,//M4_LAB
constprojectRoleData:any={
project_id:1,//M4_LAB
role_id:2,// USER
user_id:newUserId
}
thisconn.query('INSERT INTO user_project_role SET ?',projectRoleData,function(err:any,results:any,fields:any){
thisconn.query('INSERT INTO user_project_role SET ?',projectRoleData,function(err:any,results:any,fields:any){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
});
})
}
// MLAB-129: INSERT verification token
letverificationData:any={
constverificationData:any={
user_id:newUserId,
token:data.verificationToken
}
thisconn.query('INSERT INTO verification SET ?',verificationData,function(err:any,results:any,fields:any){
thisconn.query('INSERT INTO verification SET ?',verificationData,function(err:any,results:any,fields:any){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
});
})
}
// COMMIT
thisconn.commit(function(err:any){
thisconn.commit(function(err:any){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
})
}
})
})
})
});
});
});
})
})
})
callback(err)
})
},
getUserByEmail:asyncfunction(email:any){
getUserByEmail:asyncfunction(email:any){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "'+email+'"')
constrows:any=awaitdbconn.user.promise().query('SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "'+email+'"')
if(rows[0][0]){
returnrows[0][0]
}
else{returnnull}
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
getUserEmailById:asyncfunction(userId:number){
getUserEmailById:asyncfunction(userId:number){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT email FROM user WHERE id = '+userId)
constrows:any=awaitdbconn.user.promise().query('SELECT email FROM user WHERE id = '+userId)
if(rows[0][0]){
returnrows[0][0].email
}
else{returnnull}
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
checkUserEmail:asyncfunction(email:any){
checkUserEmail:asyncfunction(email:any){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT id, email FROM user WHERE email = "'+email+'"')
constrows:any=awaitdbconn.user.promise().query('SELECT id, email FROM user WHERE email = "'+email+'"')
if(rows[0][0]){
returnrows[0][0]
}
else{returnnull}
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
getUserByToken:asyncfunction(token:any){
getUserByToken:asyncfunction(token:any){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT t1.user_id, t2.email FROM userdb.credential AS t1 INNER JOIN userdb.user AS t2 ON t1.user_id = t2.id AND t1.resetPasswordToken = "'
+token+'" and resetPasswordExpires > '+Date.now())
constrows:any=awaitdbconn.user.promise().query('SELECT t1.user_id, t2.email FROM userdb.credential AS t1 INNER JOIN userdb.user AS t2 ON t1.user_id = t2.id AND t1.resetPasswordToken = "'+
varmenu=[{'name':'Informationen','combos':[{'name':'Projekte','link':'/project'},{'name':'Über das M4_LAB','link':'/projectoverview?projectID=1'},{'name':'Kontakt','link':'/account/contact'}],'type':'dropdown','link':'#'},{'name':'Zusammenarbeit','combos':[{'name':'Mailinglisten','link':'/mailinglists'},{'name':'Videokonferenzen','link':'/videoconference.html'},/* {'name':'...', 'link':'#'}*/],'type':'dropdown','link':'#'},{'name':'Events','combos':[{'name':'Veranstaltungen der HfT','link':'http://www.hft-stuttgart.de/Aktuell/Veranstaltungen/'},{'name':'Veranstaltungen der HfT Forschung','link':'https://www.hft-stuttgart.de/forschung/veranstaltungen'}],'type':'dropdown','link':'#'},{'name':'Benutzerkonto','combos':[],'type':'','link':'/account/'}];
constmenu=[{name:'Informationen',combos:[{name:'Projekte',link:'/project'},{name:'Über das M4_LAB',link:'/projectoverview?projectID=1'},{name:'Kontakt',link:'/account/contact'}],type:'dropdown',link:'#'},{name:'Zusammenarbeit',combos:[{name:'Mailinglisten',link:'/mailinglists'},{name:'Videokonferenzen',link:'/videoconference.html'}/* {'name':'...', 'link':'#'}*/],type:'dropdown',link:'#'},{name:'Events',combos:[{name:'Veranstaltungen der HfT',link:'http://www.hft-stuttgart.de/Aktuell/Veranstaltungen/'},{name:'Veranstaltungen der HfT Forschung',link:'https://www.hft-stuttgart.de/forschung/veranstaltungen'}],type:'dropdown',link:'#'},{name:'Benutzerkonto',combos:[],type:'',link:'/account/'}]