updates user groups to contain the correct db columns for start nodes, updates mappings, fixes tests.
This commit is contained in:
@@ -49,6 +49,14 @@ namespace Umbraco.Core.Models.Rdbms
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public string Icon { get; set; }
|
||||
|
||||
[Column("startContentId")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public int StartContentId { get; set; }
|
||||
|
||||
[Column("startMediaId")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
public int StartMediaId { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public List<UserGroup2AppDto> UserGroup2AppDtos { get; set; }
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.Id, dto => dto.Id);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.Alias, dto => dto.Alias);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.Name, dto => dto.Name);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.Permissions, dto => dto.DefaultPermissions);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.Icon, dto => dto.Icon);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.StartContentId, dto => dto.StartContentId);
|
||||
CacheMap<UserGroup, UserGroupDto>(src => src.StartMediaId, dto => dto.StartMediaId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -175,10 +175,10 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
|
||||
private void CreateUmbracoUserGroupData()
|
||||
{
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 1, Alias = Constants.Security.AdminGroupAlias, Name = "Administrators", DefaultPermissions = "CADMOSKTPIURZ:5F7", CreateDate = DateTime.Now, UpdateDate = DateTime.Now });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 2, Alias = "writer", Name = "Writers", DefaultPermissions = "CAH:F", CreateDate = DateTime.Now, UpdateDate = DateTime.Now });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 3, Alias = "editor", Name = "Editors", DefaultPermissions = "CADMOSKTPUZ:5F", CreateDate = DateTime.Now, UpdateDate = DateTime.Now });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 4, Alias = "translator", Name = "Translators", DefaultPermissions = "AF", CreateDate = DateTime.Now, UpdateDate = DateTime.Now });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 1, Alias = Constants.Security.AdminGroupAlias, Name = "Administrators", DefaultPermissions = "CADMOSKTPIURZ:5F7", CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Icon = "icon-medal" });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 2, Alias = "writer", Name = "Writers", DefaultPermissions = "CAH:F", CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Icon = "icon-edit" });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 3, Alias = "editor", Name = "Editors", DefaultPermissions = "CADMOSKTPUZ:5F", CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Icon = "icon-tools" });
|
||||
_database.Insert("umbracoUserGroup", "id", false, new UserGroupDto { Id = 4, Alias = "translator", Name = "Translators", DefaultPermissions = "AF", CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Icon = "icon-globe" });
|
||||
}
|
||||
|
||||
private void CreateUmbracoUser2UserGroupData()
|
||||
|
||||
@@ -25,9 +25,18 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenSevenZe
|
||||
MigrateUserPermissions();
|
||||
MigrateUserTypesToGroups();
|
||||
DeleteOldTables(tables, constraints);
|
||||
SetDefaultIcons();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDefaultIcons()
|
||||
{
|
||||
Execute.Sql(string.Format("UPDATE umbracoUserGroup SET icon = '{0}' WHERE userGroupAlias = '{1}'", "", Constants.Security.AdminGroupAlias));
|
||||
Execute.Sql(string.Format("UPDATE umbracoUserGroup SET icon = '{0}' WHERE userGroupAlias = '{1}'", "icon-edit", "writer"));
|
||||
Execute.Sql(string.Format("UPDATE umbracoUserGroup SET icon = '{0}' WHERE userGroupAlias = '{1}'", "icon-tools", "editor"));
|
||||
Execute.Sql(string.Format("UPDATE umbracoUserGroup SET icon = '{0}' WHERE userGroupAlias = '{1}'", "icon-globe", "translator"));
|
||||
}
|
||||
|
||||
private bool AddNewTables(string[] tables)
|
||||
{
|
||||
var updated = false;
|
||||
|
||||
@@ -11,17 +11,37 @@
|
||||
|
||||
function usersResource($http, umbRequestHelper, $q) {
|
||||
|
||||
function disableUser(userId) {
|
||||
if (!userId) {
|
||||
throw "userId not specified";
|
||||
function disableUsers(userIds) {
|
||||
if (!userIds) {
|
||||
throw "userIds not specified";
|
||||
}
|
||||
|
||||
//we need to create a custom query string for the usergroup array, so create it now and we can append the user groups if needed
|
||||
var qry = "userIds=" + userIds.join("&userIds=");
|
||||
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"PostDisableUser", [{ userId: userId }])),
|
||||
'Failed to disable the user ' + userId);
|
||||
"PostDisableUsers", qry)),
|
||||
'Failed to disable the users ' + userIds.join(","));
|
||||
}
|
||||
|
||||
function enableUsers(userIds) {
|
||||
if (!userIds) {
|
||||
throw "userIds not specified";
|
||||
}
|
||||
|
||||
//we need to create a custom query string for the usergroup array, so create it now and we can append the user groups if needed
|
||||
var qry = "userIds=" + userIds.join("&userIds=");
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"PostEnableUsers", qry)),
|
||||
'Failed to enable the users ' + userIds.join(","));
|
||||
}
|
||||
|
||||
function getPagedResults(options) {
|
||||
@@ -48,248 +68,41 @@
|
||||
options.orderDirection = "Descending";
|
||||
}
|
||||
|
||||
var params = {
|
||||
pageNumber: options.pageNumber,
|
||||
pageSize: options.pageSize,
|
||||
orderBy: options.orderBy,
|
||||
orderDirection: options.orderDirection,
|
||||
filter: options.filter
|
||||
};
|
||||
//we need to create a custom query string for the usergroup array, so create it now and we can append the user groups if needed
|
||||
var qry = umbRequestHelper.dictionaryToQueryString(params);
|
||||
if (options.userGroups.length > 0) {
|
||||
//we need to create a custom query string for an array
|
||||
qry += "&" + options.userGroups.join("&");
|
||||
}
|
||||
var params = {
|
||||
pageNumber: options.pageNumber,
|
||||
pageSize: options.pageSize,
|
||||
orderBy: options.orderBy,
|
||||
orderDirection: options.orderDirection,
|
||||
filter: options.filter
|
||||
};
|
||||
//we need to create a custom query string for the usergroup array, so create it now and we can append the user groups if needed
|
||||
var qry = umbRequestHelper.dictionaryToQueryString(params);
|
||||
if (options.userGroups.length > 0) {
|
||||
//we need to create a custom query string for an array
|
||||
qry += "&userGroups=" + options.userGroups.join("&userGroups=");
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"GetPagedUsers",
|
||||
qry)),
|
||||
'Failed to retrieve users paged result');
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"GetPagedUsers",
|
||||
qry)),
|
||||
'Failed to retrieve users paged result');
|
||||
}
|
||||
|
||||
function getUser(userId) {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"GetById",
|
||||
{ id: userId })),
|
||||
"Failed to retrieve data for user " + userId);
|
||||
|
||||
}
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"GetById",
|
||||
{ id: userId })),
|
||||
"Failed to retrieve data for user " + userId);
|
||||
|
||||
function getUsers() {
|
||||
var deferred = $q.defer();
|
||||
var users = [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Tammy Contreras",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Admin"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Edward Flores",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Admin"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcosmoralez/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Benjamin Mills",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Writer"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/dancounsell/128.jpg",
|
||||
"state": "disabled",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Samantha Martinez",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "pending",
|
||||
"lastLogin": ""
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Angela Stone",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/jina/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Beverly Silva",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Arthur Welch",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ashleyford/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Ruth Turner",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Translator"
|
||||
},
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "pending",
|
||||
"lastLogin": ""
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Tammy Contreras",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Translator"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Edward Flores",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Admin"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcosmoralez/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Benjamin Mills",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Writer"
|
||||
},
|
||||
{
|
||||
"name": "Translator"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/dancounsell/128.jpg",
|
||||
"state": "disabled",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Samantha Martinez",
|
||||
"userGroupName": "Editor",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "pending",
|
||||
"lastLogin": ""
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "Angela Stone",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/jina/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name": "Beverly Silva",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name": "Arthur Welch",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Editor"
|
||||
}
|
||||
],
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ashleyford/128.jpg",
|
||||
"state": "active",
|
||||
"lastLogin": "2014-04-25T01:32:21.196Z"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "Ruth Turner",
|
||||
"userGroups": [
|
||||
{
|
||||
"name": "Translator"
|
||||
}
|
||||
],
|
||||
"avatar": "",
|
||||
"state": "pending",
|
||||
"lastLogin": ""
|
||||
}
|
||||
];
|
||||
deferred.resolve(users);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
function getUserRole() {
|
||||
var deferred = $q.defer();
|
||||
var user = {
|
||||
@@ -302,6 +115,7 @@
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
//TODO: Change this over to the real resource
|
||||
function getUserGroups() {
|
||||
var deferred = $q.defer();
|
||||
var userGroups = [
|
||||
@@ -351,7 +165,8 @@
|
||||
getUsers: getUsers,
|
||||
getUserRole: getUserRole,
|
||||
getUserGroups: getUserGroups,
|
||||
disableUser: disableUser,
|
||||
disableUsers: disableUsers,
|
||||
enableUsers: enableUsers,
|
||||
getPagedResults: getPagedResults
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
|
||||
{
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>();
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>()
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Sections, opt => opt.MapFrom(x => x.AllowedSections))
|
||||
.ForMember(detail => detail.Udi, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(user => "-1," + user.Id))
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore());
|
||||
|
||||
config.CreateMap<IUser, UserDisplay>()
|
||||
.ForMember(detail => detail.UserGroups, opt => opt.MapFrom(user => user.Groups))
|
||||
|
||||
Reference in New Issue
Block a user