Commit e0da3a30 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

add /deleteProject

parent 1ea9adf8
......@@ -562,10 +562,13 @@ module.exports = function (app, config, passport, i18n) {
} else {
let project = await gitlab.getProjectById(req.query.id)
if (!project) {
console.log(" =================== error or no project found")
console.log(" ========= Error or no project found")
res.redirect('/account/services')
} else if (!project.owner) {
console.log(" ========= Project cannot be accessed, since it does not have an owner")
res.redirect('/account/services')
} else if (project.owner.id != loggedInUser.getGitlabUserId()) {
console.log(" =================== not your project")
console.log(" ========= Access denied: Not your project")
res.redirect('/account/services')
} else {
let curInformation = new projectInformation(loggedInUser.getGitlabUserId(), req.query.id, project.name, project.description,
......@@ -579,7 +582,7 @@ module.exports = function (app, config, passport, i18n) {
}
}
})
// update a website
app.post('/updateInformation', async function(req, res){
if( !req.isAuthenticated() ) {
res.redirect('/login')
......@@ -635,7 +638,35 @@ module.exports = function (app, config, passport, i18n) {
}
})
// RS: delete projektInformation?
app.delete('/deleteProject', async function(req, res){
console.log("delete project")
if( !req.isAuthenticated() ) {
res.redirect('/login')
} else {
let loggedInUser = await getLoggedInUserData(req.user.email)
let projectId = req.body.id
if (projectId) {
// check if the owner is valid
let project = await gitlab.getProjectById(projectId)
if (!project) {
console.log(" ========= Error or no project found")
} else if (!project.owner) {
console.log(" ========= Project cannot be accessed, since it does not have an owner")
} else if (project.owner.id != loggedInUser.getGitlabUserId()) {
console.log(" ========= Access denied: Not your project")
} else {
// delete project
let project = await gitlab.deleteProjectById(projectId)
if (project.error) {
res.flash("error", "Project cannot be deleted. Please try again.")
}
}
}
res.redirect('/account/services')
}
})
// ============= NEW USERS REGISTRATION ===========================
app.get('/registration', function(req, res) {
......
Markdown is supported
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