New backoffice: User controller (#13947)
* Add UserResponseModel * Add factory to created UserResponseModel * Add GetByKey controller * Add GetAllUsers endpoint * User proper response model * Make naming consistent * Order by username in GetAll * Add user filter endpoint * Fix includer user states * Remove gravatar from the backend * Send user avatars in response * Add create user model * start working on create * Validate the create model * Add authorization to create * Use UserRepository instead of UserService to ValidateSessíonId * Create IBackofficeUserStore interface This is essentially a core-friendly version of the BackOfficeUserStore, additionally it contains basic methods for managing users, I.E. Get users, save users, create users, etc. * Remove more usages of user service * Remove usages of IUserService in BackofficeUserStore * Add documentation * Fix tests and DI * add IBackOfficeUserStoreAccessor to resolve it in singleton services * Resolve circular dependency * Remove obsolete constructor * Add core friendly user manager * Finish createasync in user service * Add WIP create endpoint * Save newly creates users user groups * Use service scope for user service * Remove now unnecessary accessors * Add response types * Add update user endpoint * Add EmailUserInviteSender * Add technology free way of creating confirmation token * Add invite uri provider * Add invite user to user service * Add invite user controller * Add delete endpoint * Add operation status responses * Add operation status responses * Added temporary file uploads including a repository implementation using local temp folder. * Add Disable users endpoint * missing files * Fixed copy paste error * Fix create users return type * Updated OpenApi.json * Updated OpenApi.json * Handle if created failed in identity * Add enable user * Make users plural in enable/disable We're doing the operation on multiple entities * Added file extension check * Add unlock user endpoint * Clean up. Removed old TemporaryFileService and UploadFileService and updated dictionary items to use this new items * Clean up * Add reset password * Add UpdateUserGroupsOnUsers method * Add UpdateUserGroups * Get rid of stream directly on TemporaryFileModel, and use delegate to open stream instead. * Fix post merge * Use keys instead of IDs * Add ClearAvatar endpoint * Review changes * Moved models to their own files * Reverted launch settings * Move enlist extension to its own namespace * Create set avatar endpoint * Add reponse types * Remove infrastructure extension after merge * Add Cmapatibility suppressions * Add test suppression * Add integration tests * Fix issue found in tests * Add invited user to UserInvitationResult * Add more tests * Add update tests * Hide different tests under parent * Return DuplicatUserName user operation status if username matches an email * Add update tests * Change sorted set to HashSet It doesn't work if it's not IComparable * Change ID to Key when checking super * Add get tests * Add more GetAllTests * Move tests to the right namespace * Add filter test * Fix including disabled users bug found by test * Add test to ensure invited user state * Add test case for UserState.All * Add more filter tests * Add enable disable tests * Add resolver for keys and ids * Replace usages of IUserService with IUserIdKeyResolver * Add CompatibilitySuppressions * Add UserIdKeyResolverTests * Fix UserIdKeyResolver * Add missing user operation results * Updates from review * ID not key * Post instead of patch * Use set instead of params for enable/disable * Don't call to array * Use sets for usergroup keys and user keys instead * LanguageIsoCode instead of Language * Update CompatibilitySuppressions after changin enumerable to set --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk> Co-authored-by: kjac <kja@umbraco.dk>
This commit is contained in:
@@ -22,7 +22,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
private readonly ILanguageRepository _languageRepository;
|
||||
private readonly ILanguageService _languageService;
|
||||
private readonly IDictionaryItemService _dictionaryItemService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IUserIdKeyResolver _userIdKeyResolver;
|
||||
|
||||
[Obsolete("Please use constructor with language, dictionary and user services. Will be removed in V15")]
|
||||
public LocalizationService(
|
||||
@@ -41,7 +41,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
languageRepository,
|
||||
StaticServiceProvider.Instance.GetRequiredService<ILanguageService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<IDictionaryItemService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<IUserService>())
|
||||
StaticServiceProvider.Instance.GetRequiredService<IUserIdKeyResolver>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
ILanguageRepository languageRepository,
|
||||
ILanguageService languageService,
|
||||
IDictionaryItemService dictionaryItemService,
|
||||
IUserService userService)
|
||||
IUserIdKeyResolver userIdKeyResolver)
|
||||
: base(provider, loggerFactory, eventMessagesFactory)
|
||||
{
|
||||
_dictionaryRepository = dictionaryRepository;
|
||||
@@ -63,7 +63,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
_languageRepository = languageRepository;
|
||||
_languageService = languageService;
|
||||
_dictionaryItemService = dictionaryItemService;
|
||||
_userService = userService;
|
||||
_userIdKeyResolver = userIdKeyResolver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -220,8 +220,8 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
/// <param name="userId">Optional id of the user saving the dictionary item</param>
|
||||
[Obsolete("Please use IDictionaryItemService for dictionary item operations. Will be removed in V15.")]
|
||||
public void Save(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
Guid currentUserKey = _userService.GetUserById(userId)?.Key ?? Constants.Security.SuperUserKey;
|
||||
{ ;
|
||||
Guid currentUserKey = _userIdKeyResolver.GetAsync(userId).GetAwaiter().GetResult() ?? Constants.Security.SuperUserKey;
|
||||
if (dictionaryItem.Id > 0)
|
||||
{
|
||||
_dictionaryItemService.UpdateAsync(dictionaryItem, currentUserKey).GetAwaiter().GetResult();
|
||||
@@ -241,7 +241,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
[Obsolete("Please use IDictionaryItemService for dictionary item operations. Will be removed in V15.")]
|
||||
public void Delete(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
Guid currentUserKey = _userService.GetUserById(userId)?.Key ?? Constants.Security.SuperUserKey;
|
||||
Guid currentUserKey = _userIdKeyResolver.GetAsync(userId).GetAwaiter().GetResult() ?? Constants.Security.SuperUserKey;
|
||||
_dictionaryItemService.DeleteAsync(dictionaryItem.Key, currentUserKey).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
[Obsolete("Please use ILanguageService for language operations. Will be removed in V15.")]
|
||||
public void Save(ILanguage language, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
Guid currentUserKey = _userService.GetUserById(userId)?.Key ?? Constants.Security.SuperUserKey;
|
||||
Guid currentUserKey = _userIdKeyResolver.GetAsync(userId).GetAwaiter().GetResult() ?? Constants.Security.SuperUserKey;
|
||||
Attempt<ILanguage, LanguageOperationStatus> result = language.Id > 0
|
||||
? _languageService.UpdateAsync(language, currentUserKey).GetAwaiter().GetResult()
|
||||
: _languageService.CreateAsync(language, currentUserKey).GetAwaiter().GetResult();
|
||||
@@ -341,7 +341,7 @@ internal class LocalizationService : RepositoryService, ILocalizationService
|
||||
[Obsolete("Please use ILanguageService for language operations. Will be removed in V15.")]
|
||||
public void Delete(ILanguage language, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
Guid currentUserKey = _userService.GetUserById(userId)?.Key ?? Constants.Security.SuperUserKey;
|
||||
Guid currentUserKey = _userIdKeyResolver.GetAsync(userId).GetAwaiter().GetResult() ?? Constants.Security.SuperUserKey;
|
||||
_languageService.DeleteAsync(language.IsoCode, currentUserKey).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user