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){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
throwerr
});
})
}
}
letnewUserId:number=results.insertId
constnewUserId:number=results.insertId
// set password
// set password
varcredentialData:any={
constcredentialData:any={
user_id:newUserId,
user_id:newUserId,
password:data.password
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){
if(err){
returnthisconn.rollback(function(){
returnthisconn.rollback(function(){
throwerr
throwerr
});
})
}
// set default user-project-role
varprojectRoleData: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){
if(err){
returnthisconn.rollback(function(){
throwerr
});
}
// MLAB-129: INSERT verification token
letverificationData:any={
user_id:newUserId,
token:data.verificationToken
}
thisconn.query('INSERT INTO verification SET ?',verificationData,function(err:any,results:any,fields:any){
if(err){
returnthisconn.rollback(function(){
throwerr
});
}
// COMMIT
thisconn.commit(function(err:any){
if(err){
returnthisconn.rollback(function(){
throwerr
})
}
})
})
})
});
});
});
callback(err)
})
},
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+'"')
if(rows[0][0]){
returnrows[0][0]
}
else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
getUserEmailById:asyncfunction(userId:number){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT email FROM user WHERE id = '+userId)
if(rows[0][0]){
returnrows[0][0].email
}
else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
checkUserEmail:asyncfunction(email:any){
try{
letrows:any=awaitdbconn.user.promise().query('SELECT id, email FROM user WHERE email = "'+email+'"')
if(rows[0][0]){
returnrows[0][0]
}
else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
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())
thisconn.query('UPDATE user SET ? WHERE id ='+userData.id,userData,function(err:any,rows:any,fields:any){
}
if(err){
thisconn.query('INSERT INTO verification SET ?',verificationData,function(err:any,results:any,fields:any){
returnthisconn.rollback(function(){throwerr})
if(err){
}
returnthisconn.rollback(function(){
// delete verification token
throwerr
thisconn.query('DELETE FROM verification WHERE user_id = '+userData.id,function(err:any,rows:any,fields:any){
})
if(err){
}
returnthisconn.rollback(function(){throwerr})
// COMMIT
}
thisconn.commit(function(err:any){
// COMMIT
if(err){
thisconn.commit(function(err:any){
returnthisconn.rollback(function(){
if(err){
throwerr
returnthisconn.rollback(function(){throwerr})
}
})
})
})
}
})
})
})
})
})
callback(err)
})
})
})
},
})
/* ===== GitLab ===== */
callback(err)
getGitlabId:asyncfunction(userId:number){
})
try{
},
letrows:any=awaitdbconn.user.promise().query('SELECT gu.gitlab_userId FROM user_gitlab gu, user u WHERE u.id = "'+userId+'" and gu.user_id = u.id')
getUserByEmail:asyncfunction(email:any){
if(rows[0][0]){
try{
returnrows[0][0].gitlab_userId
constrows:any=awaitdbconn.user.promise().query('SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "'+email+'"')
}else{
if(rows[0][0]){
returnnull
returnrows[0][0]
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
getUserEmailById:asyncfunction(userId:number){
try{
constrows:any=awaitdbconn.user.promise().query('SELECT email FROM user WHERE id = '+userId)
if(rows[0][0]){
returnrows[0][0].email
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
checkUserEmail:asyncfunction(email:any){
try{
constrows:any=awaitdbconn.user.promise().query('SELECT id, email FROM user WHERE email = "'+email+'"')
if(rows[0][0]){
returnrows[0][0]
}else{returnnull}
}catch(err){
console.error(err)
}
returnnull
},
getUserByToken:asyncfunction(token:any){
try{
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/'}]