Generalize some methods in AccountController and UserManagementController.

This commit is contained in:
takezoe
2013-07-10 20:44:28 +09:00
parent 7a3c61a8d0
commit 9d61f73e22
3 changed files with 21 additions and 28 deletions

View File

@@ -77,17 +77,10 @@ trait AccountControllerBase extends AccountManagementControllerBase with FlashMa
mailAddress = form.mailAddress,
url = form.url))
if(form.clearImage){
account.image.map { image =>
new java.io.File(getUserUploadDir(userName), image).delete()
updateAvatarImage(userName, None)
}
} else {
updateImage(userName, form.fileId)
}
updateImage(userName, form.fileId, form.clearImage)
flash += "info" -> "Account information has been updated."
redirect("/%s/_edit".format(userName))
} getOrElse NotFound
})
@@ -100,7 +93,7 @@ trait AccountControllerBase extends AccountManagementControllerBase with FlashMa
post("/register", newForm){ form =>
if(loadSystemSettings().allowAccountRegistration){
createAccount(form.userName, encrypt(form.password), form.mailAddress, false, form.url)
updateImage(form.userName, form.fileId)
updateImage(form.userName, form.fileId, false)
redirect("/signin")
} else NotFound
}