diff --git a/src/main/scala/app/SignInController.scala b/src/main/scala/app/SignInController.scala index 06f11cc..e238ccf 100644 --- a/src/main/scala/app/SignInController.scala +++ b/src/main/scala/app/SignInController.scala @@ -27,9 +27,10 @@ post("/signin", form){ form => val settings = loadSystemSettings() - settings.authType match { - case "LDAP" => ldapAuthentication(form, settings) - case _ => defaultAuthentication(form) + if(settings.ldapAuthentication){ + ldapAuthentication(form, settings) + } else { + defaultAuthentication(form) } } diff --git a/src/main/scala/app/SystemSettingsController.scala b/src/main/scala/app/SystemSettingsController.scala index 60f3700..03df403 100644 --- a/src/main/scala/app/SystemSettingsController.scala +++ b/src/main/scala/app/SystemSettingsController.scala @@ -23,8 +23,8 @@ "password" -> trim(label("SMTP Password", optional(text()))), "ssl" -> trim(label("Enable SSL", optional(boolean()))) )(Smtp.apply)), - "authType" -> trim(label("Auth Type", text(required))), - "ldap" -> optional(_.get("authType") == Some("LDAP"), mapping( + "ldapAuthentication" -> trim(label("LDAP", boolean())), + "ldap" -> optionalIfNotChecked("ldapAuthentication", mapping( "host" -> trim(label("LDAP host", text(required))), "port" -> trim(label("LDAP port", number(required))), "baseDN" -> trim(label("BaseDN", text(required))), diff --git a/src/main/scala/service/SystemSettingsService.scala b/src/main/scala/service/SystemSettingsService.scala index d639526..ee83a12 100644 --- a/src/main/scala/service/SystemSettingsService.scala +++ b/src/main/scala/service/SystemSettingsService.scala @@ -19,7 +19,8 @@ smtp.ssl.foreach(x => props.setProperty(SmtpSsl, x.toString)) } } - if(settings.authType == "LDAP"){ + props.setProperty(LdapAuthentication, settings.ldapAuthentication.toString) + if(settings.ldapAuthentication){ settings.ldap.map { ldap => props.setProperty(LdapHost, ldap.host) props.setProperty(LdapPort, ldap.port.toString) @@ -51,14 +52,14 @@ } else { None }, - getValue(props, AuthType, ""), - if(getValue(props, AuthType, "") == "LDAP"){ + getValue(props, LdapAuthentication, false), + if(getValue(props, LdapAuthentication, false)){ Some(Ldap( getValue(props, LdapHost, ""), getValue(props, LdapPort, 389), getValue(props, LdapBaseDN, ""), getValue(props, LdapUserNameAttribute, "uid"), - getValue(props, LdapUserNameAttribute, "mail"))) + getValue(props, LdapMailAddressAttribute, "mail"))) } else { None } @@ -75,7 +76,7 @@ gravatar: Boolean, notification: Boolean, smtp: Option[Smtp], - authType: String, + ldapAuthentication: Boolean, ldap: Option[Ldap]) case class Ldap( @@ -94,13 +95,13 @@ private val AllowAccountRegistration = "allow_account_registration" private val Gravatar = "gravatar" - private val AuthType = "auth_type" private val Notification = "notification" private val SmtpHost = "smtp.host" private val SmtpPort = "smtp.port" private val SmtpUser = "smtp.user" private val SmtpPassword = "smtp.password" private val SmtpSsl = "smtp.ssl" + private val LdapAuthentication = "ldap_authentication" private val LdapHost = "ldap.host" private val LdapPort = "ldap.port" private val LdapBaseDN = "ldap.baseDN" diff --git a/src/main/twirl/admin/system.scala.html b/src/main/twirl/admin/system.scala.html index 3e77d0e..daebbc7 100644 --- a/src/main/twirl/admin/system.scala.html +++ b/src/main/twirl/admin/system.scala.html @@ -40,13 +40,7 @@
- @@ -147,9 +141,8 @@ $('.notification input').prop('disabled', !$(this).prop('checked')); }).change(); - $('input[name=authType]').click(function(){ - $('.ldap input').prop('disabled', $('input[name=authType]:checked').val() != "LDAP"); - }); - $('input[name=authType]:checked').click(); + $('#ldapAuthentication').change(function(){ + $('.ldap input').prop('disabled', !$(this).prop('checked')); + }).change(); }); \ No newline at end of file