mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
send default user type back to client
This commit is contained in:
@@ -77,12 +77,33 @@ public class ScmState
|
|||||||
WebSecurityContext securityContext,
|
WebSecurityContext securityContext,
|
||||||
Collection<Type> repositoryTypes,
|
Collection<Type> repositoryTypes,
|
||||||
ScmClientConfig clientConfig)
|
ScmClientConfig clientConfig)
|
||||||
|
{
|
||||||
|
this(provider, securityContext, repositoryTypes, null, clientConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs {@link ScmState} object.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param provider - context provider
|
||||||
|
* @param securityContext - security context of the current user
|
||||||
|
* @param repositoryTypes - available repository types
|
||||||
|
* @param clientConfig - client configuration
|
||||||
|
* @param defaultUserType = Default user type
|
||||||
|
*
|
||||||
|
* @since 1.14
|
||||||
|
*/
|
||||||
|
public ScmState(SCMContextProvider provider,
|
||||||
|
WebSecurityContext securityContext,
|
||||||
|
Collection<Type> repositoryTypes, String defaultUserType,
|
||||||
|
ScmClientConfig clientConfig)
|
||||||
{
|
{
|
||||||
this.version = provider.getVersion();
|
this.version = provider.getVersion();
|
||||||
this.user = securityContext.getUser();
|
this.user = securityContext.getUser();
|
||||||
this.groups = securityContext.getGroups();
|
this.groups = securityContext.getGroups();
|
||||||
this.repositoryTypes = repositoryTypes;
|
this.repositoryTypes = repositoryTypes;
|
||||||
this.clientConfig = clientConfig;
|
this.clientConfig = clientConfig;
|
||||||
|
this.defaultUserType = defaultUserType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -98,6 +119,19 @@ public class ScmState
|
|||||||
return clientConfig;
|
return clientConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default user type
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return default user type
|
||||||
|
*
|
||||||
|
* @since 1.14
|
||||||
|
*/
|
||||||
|
public String getDefaultUserType()
|
||||||
|
{
|
||||||
|
return defaultUserType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link java.util.Collection} of groups names which are associated
|
* Returns a {@link java.util.Collection} of groups names which are associated
|
||||||
* to the current user.
|
* to the current user.
|
||||||
@@ -168,6 +202,18 @@ public class ScmState
|
|||||||
this.clientConfig = clientConfig;
|
this.clientConfig = clientConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the default user type
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param defaultUserType default user type
|
||||||
|
* @since 1.14
|
||||||
|
*/
|
||||||
|
public void setDefaultUserType(String defaultUserType)
|
||||||
|
{
|
||||||
|
this.defaultUserType = defaultUserType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the groups.
|
* Setter for the groups.
|
||||||
*
|
*
|
||||||
@@ -231,6 +277,9 @@ public class ScmState
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private ScmClientConfig clientConfig;
|
private ScmClientConfig clientConfig;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String defaultUserType;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Collection<String> groups;
|
private Collection<String> groups;
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import sonia.scm.ScmState;
|
|||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.RepositoryManager;
|
||||||
import sonia.scm.user.User;
|
import sonia.scm.user.User;
|
||||||
|
import sonia.scm.user.UserManager;
|
||||||
import sonia.scm.web.security.WebSecurityContext;
|
import sonia.scm.web.security.WebSecurityContext;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -93,17 +94,19 @@ public class AuthenticationResource
|
|||||||
* @param contextProvider
|
* @param contextProvider
|
||||||
* @param configuration
|
* @param configuration
|
||||||
* @param repositoryManger
|
* @param repositoryManger
|
||||||
|
* @param userManager
|
||||||
* @param securityContextProvider
|
* @param securityContextProvider
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public AuthenticationResource(
|
public AuthenticationResource(
|
||||||
SCMContextProvider contextProvider, ScmConfiguration configuration,
|
SCMContextProvider contextProvider, ScmConfiguration configuration,
|
||||||
RepositoryManager repositoryManger,
|
RepositoryManager repositoryManger, UserManager userManager,
|
||||||
Provider<WebSecurityContext> securityContextProvider)
|
Provider<WebSecurityContext> securityContextProvider)
|
||||||
{
|
{
|
||||||
this.contextProvider = contextProvider;
|
this.contextProvider = contextProvider;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.repositoryManger = repositoryManger;
|
this.repositoryManger = repositoryManger;
|
||||||
|
this.userManager = userManager;
|
||||||
this.securityContextProvider = securityContextProvider;
|
this.securityContextProvider = securityContextProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +250,7 @@ public class AuthenticationResource
|
|||||||
{
|
{
|
||||||
return new ScmState(contextProvider, securityContext,
|
return new ScmState(contextProvider, securityContext,
|
||||||
repositoryManger.getConfiguredTypes(),
|
repositoryManger.getConfiguredTypes(),
|
||||||
|
userManager.getDefaultType(),
|
||||||
new ScmClientConfig(configuration.getDateFormat(),
|
new ScmClientConfig(configuration.getDateFormat(),
|
||||||
configuration.isDisableGroupingGrid()));
|
configuration.isDisableGroupingGrid()));
|
||||||
}
|
}
|
||||||
@@ -264,4 +268,7 @@ public class AuthenticationResource
|
|||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Provider<WebSecurityContext> securityContextProvider;
|
private Provider<WebSecurityContext> securityContextProvider;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private UserManager userManager;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ Sonia.group.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug( 'create group: ' + item.name );
|
console.debug( 'create group: ' + item.name );
|
||||||
}
|
}
|
||||||
// item.type = 'xml';
|
item.type = state.defaultUserType;
|
||||||
|
|
||||||
var url = restUrl + 'groups.json';
|
var url = restUrl + 'groups.json';
|
||||||
var el = this.el;
|
var el = this.el;
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
|
|
||||||
var securitySection = null;
|
var securitySection = null;
|
||||||
|
|
||||||
if ( state.user.type == 'xml' && state.user.name != 'anonymous' ){
|
if ( state.user.type == state.defaultUserType && state.user.name != 'anonymous' ){
|
||||||
securitySection = {
|
securitySection = {
|
||||||
title: this.sectionSecurityText,
|
title: this.sectionSecurityText,
|
||||||
links: [{
|
links: [{
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
helpText: this.mailHelpText
|
helpText: this.mailHelpText
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if ( this.item == null || this.item.type == 'xml' ){
|
if ( this.item == null || this.item.type == state.defaultUserType ){
|
||||||
items.push({
|
items.push({
|
||||||
fieldLabel: this.passwordText,
|
fieldLabel: this.passwordText,
|
||||||
id: 'pwd',
|
id: 'pwd',
|
||||||
@@ -107,7 +107,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
},
|
},
|
||||||
|
|
||||||
isReadOnly: function(){
|
isReadOnly: function(){
|
||||||
return this.item != null && this.item.type != 'xml';
|
return this.item != null && this.item.type != state.defaultUserType;
|
||||||
},
|
},
|
||||||
|
|
||||||
fixRequest: function(user){
|
fixRequest: function(user){
|
||||||
@@ -150,7 +150,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
}
|
}
|
||||||
this.fixRequest(user);
|
this.fixRequest(user);
|
||||||
// set user type
|
// set user type
|
||||||
user.type = 'xml';
|
user.type = state.defaultUserType;
|
||||||
var url = restUrl + 'users.json';
|
var url = restUrl + 'users.json';
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
url: url,
|
url: url,
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
scope: this
|
scope: this
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if ( item.type == 'xml' ){
|
if ( item.type == state.defaultUserType ){
|
||||||
panel.getForm().setValues([
|
panel.getForm().setValues([
|
||||||
{id: 'password', value: dummyPassword},
|
{id: 'password', value: dummyPassword},
|
||||||
{id: 'password-confirm', value: dummyPassword}
|
{id: 'password-confirm', value: dummyPassword}
|
||||||
|
|||||||
Reference in New Issue
Block a user