Added overload to User object to be created from an IUser object. Added GetUserSections to IUserService.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
@@ -44,5 +45,11 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="sectionAlias"></param>
|
||||
void DeleteSectionFromAllUsers(string sectionAlias);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of the sections that the user is allowed access to
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<string> GetUserSections(IUser user);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Events;
|
||||
@@ -139,6 +140,21 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the user's applications that they are allowed to access
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<string> GetUserSections(IUser user)
|
||||
{
|
||||
//TODO: We need to cache this result, should all caching be done in the repo level ?
|
||||
|
||||
var uow = _uowProvider.GetUnitOfWork();
|
||||
var sql = new Sql();
|
||||
sql.Select("app").From<User2AppDto>().Where("[user] = @userID", new {userID = user.Id});
|
||||
return uow.Database.Fetch<string>(sql);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new user for logging into the umbraco backoffice
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Web.Caching;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -37,6 +38,23 @@ namespace umbraco.BusinessLogic
|
||||
get { return Application.SqlHelper; }
|
||||
}
|
||||
|
||||
internal User(IUser user)
|
||||
{
|
||||
_userNoConsole = user.NoConsole;
|
||||
_userDisabled = user.IsLockedOut;
|
||||
_name = user.Name;
|
||||
_loginname = user.Username;
|
||||
_email = user.Email;
|
||||
_language = user.Language;
|
||||
_startnodeid = user.StartContentId;
|
||||
_startmediaid = user.StartMediaId;
|
||||
//this is cached, so should be 'ok'
|
||||
_usertype = UserType.GetUserType(user.UserType.Id);
|
||||
_defaultToLiveEditing = user.DefaultToLiveEditing;
|
||||
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="User"/> class.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user