diff --git a/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java b/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java index 4750361d15..9ecec82463 100644 --- a/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java +++ b/scm-webapp/src/main/java/sonia/scm/template/TemplateServlet.java @@ -39,10 +39,13 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; import com.google.inject.Singleton; +import freemarker.template.Configuration; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sonia.scm.SCMContextProvider; +import sonia.scm.config.ScmConfiguration; import sonia.scm.resources.ResourceManager; import sonia.scm.resources.ResourceType; import sonia.scm.util.IOUtil; @@ -97,17 +100,18 @@ public class TemplateServlet extends HttpServlet * * * @param context - * @param templateHandler * @param templateEngineFactory + * @param configuration * @param resourceManager */ @Inject public TemplateServlet(SCMContextProvider context, TemplateEngineFactory templateEngineFactory, - ResourceManager resourceManager) + ResourceManager resourceManager, ScmConfiguration configuration) { this.templateEngineFactory = templateEngineFactory; this.resourceManager = resourceManager; + this.configuration = configuration; this.version = context.getVersion(); } @@ -131,6 +135,7 @@ public class TemplateServlet extends HttpServlet String contextPath = request.getContextPath(); params.put("contextPath", contextPath); + params.put("configuration", configuration); params.put("version", version); params.put("scripts", resourceManager.getResources(ResourceType.SCRIPT)); @@ -237,11 +242,14 @@ public class TemplateServlet extends HttpServlet //~--- fields --------------------------------------------------------------- /** Field description */ - private ResourceManager resourceManager; + private final ScmConfiguration configuration; /** Field description */ - private TemplateEngineFactory templateEngineFactory; + private final ResourceManager resourceManager; /** Field description */ - private String version; + private final TemplateEngineFactory templateEngineFactory; + + /** Field description */ + private final String version; } diff --git a/scm-webapp/src/main/webapp/index.mustache b/scm-webapp/src/main/webapp/index.mustache index 32929592a7..b67ec3f457 100644 --- a/scm-webapp/src/main/webapp/index.mustache +++ b/scm-webapp/src/main/webapp/index.mustache @@ -48,6 +48,9 @@ locale: '{{locale}}', country: '{{country}}' }; + var scmGlobalConfiguration = { + anonymousAccessEnabled: {{configuration.anonymousAccessEnabled}} + }; diff --git a/scm-webapp/src/main/webapp/resources/js/login/sonia.login.form.js b/scm-webapp/src/main/webapp/resources/js/login/sonia.login.form.js index d3451da121..b27f2484b4 100644 --- a/scm-webapp/src/main/webapp/resources/js/login/sonia.login.form.js +++ b/scm-webapp/src/main/webapp/resources/js/login/sonia.login.form.js @@ -44,6 +44,21 @@ Sonia.login.Form = Ext.extend(Ext.FormPanel,{ rememberMeText: 'Remember me', initComponent: function(){ + var buttons = []; + if (scmGlobalConfiguration.anonymousAccessEnabled){ + buttons.push({ + text: this.cancelText, + scope: this, + handler: this.cancel + }); + } + buttons.push({ + id: 'loginButton', + text: this.loginText, + formBind: true, + scope: this, + handler: this.authenticate + }); var config = { labelWidth: 120, @@ -85,17 +100,7 @@ Sonia.login.Form = Ext.extend(Ext.FormPanel,{ name: 'rememberMe', inputValue: 'true' }], - buttons:[{ - text: this.cancelText, - scope: this, - handler: this.cancel - },{ - id: 'loginButton', - text: this.loginText, - formBind: true, - scope: this, - handler: this.authenticate - }] + buttons: buttons }; this.addEvents('cancel', 'failure');