mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
remove cancel button on login window if anonymous access is disabled, see issue #396
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
locale: '{{locale}}',
|
||||
country: '{{country}}'
|
||||
};
|
||||
var scmGlobalConfiguration = {
|
||||
anonymousAccessEnabled: {{configuration.anonymousAccessEnabled}}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!--compress-->
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user