mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-11 07:55:55 +01:00
33 lines
1.0 KiB
Scala
33 lines
1.0 KiB
Scala
package app
|
|
|
|
import service.{AccountService, SystemSettingsService}
|
|
import SystemSettingsService._
|
|
import util.AdminAuthenticator
|
|
import jp.sf.amateras.scalatra.forms._
|
|
import org.scalatra.FlashMapSupport
|
|
|
|
class SystemSettingsController extends SystemSettingsControllerBase
|
|
with SystemSettingsService with AccountService with AdminAuthenticator
|
|
|
|
trait SystemSettingsControllerBase extends ControllerBase with FlashMapSupport {
|
|
self: SystemSettingsService with AccountService with AdminAuthenticator =>
|
|
|
|
private case class SystemSettingsForm(allowAccountRegistration: Boolean)
|
|
|
|
private val form = mapping(
|
|
"allowAccountRegistration" -> trim(label("Account registration", boolean()))
|
|
)(SystemSettingsForm.apply)
|
|
|
|
|
|
get("/admin/system")(adminOnly {
|
|
admin.html.system(loadSystemSettings(), flash.get("info"))
|
|
})
|
|
|
|
post("/admin/system", form)(adminOnly { form =>
|
|
saveSystemSettings(SystemSettings(form.allowAccountRegistration))
|
|
flash += "info" -> "System settings has been updated."
|
|
redirect("/admin/system")
|
|
})
|
|
|
|
}
|