Skip to content

Commit

Permalink
Merge pull request #3218 from sbwalker/dev
Browse files Browse the repository at this point in the history
include User Settings when calling UserService
  • Loading branch information
sbwalker authored Sep 1, 2023
2 parents ab93d0a + d491aee commit c151c6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Oqtane.Server/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ public class UserController : Controller
private readonly IUserManager _userManager;
private readonly ISiteRepository _sites;
private readonly IUserPermissions _userPermissions;
private readonly ISettingRepository _settings;
private readonly IJwtManager _jwtManager;
private readonly ILogManager _logger;

public UserController(IUserRepository users, ITenantManager tenantManager, IUserManager userManager, ISiteRepository sites, IUserPermissions userPermissions, IJwtManager jwtManager, ILogManager logger)
public UserController(IUserRepository users, ITenantManager tenantManager, IUserManager userManager, ISiteRepository sites, IUserPermissions userPermissions, ISettingRepository settings, IJwtManager jwtManager, ILogManager logger)
{
_users = users;
_tenantManager = tenantManager;
_userManager = userManager;
_sites = sites;
_userPermissions = userPermissions;
_settings = settings;
_jwtManager = jwtManager;
_logger = logger;
}
Expand All @@ -52,6 +54,12 @@ public User Get(int id, string siteid)
{
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
}
else
{
List<Setting> settings = _settings.GetSettings(EntityNames.User, user.UserId).ToList();
user.Settings = settings.Where(item => !item.IsPrivate || _userPermissions.GetUser(User).UserId == user.UserId)
.ToDictionary(setting => setting.SettingName, setting => setting.SettingValue);
}
return Filter(user);
}
else
Expand All @@ -75,6 +83,12 @@ public User Get(string name, string email, string siteid)
{
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
}
else
{
List<Setting> settings = _settings.GetSettings(EntityNames.User, user.UserId).ToList();
user.Settings = settings.Where(item => !item.IsPrivate || _userPermissions.GetUser(User).UserId == user.UserId)
.ToDictionary(setting => setting.SettingName, setting => setting.SettingValue);
}
return Filter(user);
}
else
Expand Down
7 changes: 7 additions & 0 deletions Oqtane.Shared/Models/User.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace Oqtane.Models
Expand Down Expand Up @@ -105,5 +106,11 @@ public string FolderPath
/// </summary>
[NotMapped]
public bool EmailConfirmed { get; set; }

/// <summary>
/// Public User Settings
/// </summary>
[NotMapped]
public Dictionary<string, string> Settings { get; set; }
}
}

0 comments on commit c151c6f

Please sign in to comment.