UserController.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Jellyfin.Api.Constants;
  7. using Jellyfin.Api.Helpers;
  8. using Jellyfin.Api.Models.UserDtos;
  9. using Jellyfin.Data.Enums;
  10. using MediaBrowser.Common.Net;
  11. using MediaBrowser.Controller.Authentication;
  12. using MediaBrowser.Controller.Configuration;
  13. using MediaBrowser.Controller.Devices;
  14. using MediaBrowser.Controller.Library;
  15. using MediaBrowser.Controller.Net;
  16. using MediaBrowser.Controller.Session;
  17. using MediaBrowser.Model.Configuration;
  18. using MediaBrowser.Model.Dto;
  19. using MediaBrowser.Model.Users;
  20. using Microsoft.AspNetCore.Authorization;
  21. using Microsoft.AspNetCore.Http;
  22. using Microsoft.AspNetCore.Mvc;
  23. namespace Jellyfin.Api.Controllers
  24. {
  25. /// <summary>
  26. /// User controller.
  27. /// </summary>
  28. [Route("Users")]
  29. public class UserController : BaseJellyfinApiController
  30. {
  31. private readonly IUserManager _userManager;
  32. private readonly ISessionManager _sessionManager;
  33. private readonly INetworkManager _networkManager;
  34. private readonly IDeviceManager _deviceManager;
  35. private readonly IAuthorizationContext _authContext;
  36. private readonly IServerConfigurationManager _config;
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="UserController"/> class.
  39. /// </summary>
  40. /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
  41. /// <param name="sessionManager">Instance of the <see cref="ISessionManager"/> interface.</param>
  42. /// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
  43. /// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
  44. /// <param name="authContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
  45. /// <param name="config">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
  46. public UserController(
  47. IUserManager userManager,
  48. ISessionManager sessionManager,
  49. INetworkManager networkManager,
  50. IDeviceManager deviceManager,
  51. IAuthorizationContext authContext,
  52. IServerConfigurationManager config)
  53. {
  54. _userManager = userManager;
  55. _sessionManager = sessionManager;
  56. _networkManager = networkManager;
  57. _deviceManager = deviceManager;
  58. _authContext = authContext;
  59. _config = config;
  60. }
  61. /// <summary>
  62. /// Gets a list of users.
  63. /// </summary>
  64. /// <param name="isHidden">Optional filter by IsHidden=true or false.</param>
  65. /// <param name="isDisabled">Optional filter by IsDisabled=true or false.</param>
  66. /// <response code="200">Users returned.</response>
  67. /// <returns>An <see cref="IEnumerable{UserDto}"/> containing the users.</returns>
  68. [HttpGet]
  69. [Authorize(Policy = Policies.DefaultAuthorization)]
  70. [ProducesResponseType(StatusCodes.Status200OK)]
  71. public ActionResult<IEnumerable<UserDto>> GetUsers(
  72. [FromQuery] bool? isHidden,
  73. [FromQuery] bool? isDisabled)
  74. {
  75. var users = Get(isHidden, isDisabled, false, false);
  76. return Ok(users);
  77. }
  78. /// <summary>
  79. /// Gets a list of publicly visible users for display on a login screen.
  80. /// </summary>
  81. /// <response code="200">Public users returned.</response>
  82. /// <returns>An <see cref="IEnumerable{UserDto}"/> containing the public users.</returns>
  83. [HttpGet("Public")]
  84. [ProducesResponseType(StatusCodes.Status200OK)]
  85. public ActionResult<IEnumerable<UserDto>> GetPublicUsers()
  86. {
  87. // If the startup wizard hasn't been completed then just return all users
  88. if (!_config.Configuration.IsStartupWizardCompleted)
  89. {
  90. return Ok(Get(false, false, false, false));
  91. }
  92. return Ok(Get(false, false, true, true));
  93. }
  94. /// <summary>
  95. /// Gets a user by Id.
  96. /// </summary>
  97. /// <param name="userId">The user id.</param>
  98. /// <response code="200">User returned.</response>
  99. /// <response code="404">User not found.</response>
  100. /// <returns>An <see cref="UserDto"/> with information about the user or a <see cref="NotFoundResult"/> if the user was not found.</returns>
  101. [HttpGet("{userId}")]
  102. [Authorize(Policy = Policies.IgnoreParentalControl)]
  103. [ProducesResponseType(StatusCodes.Status200OK)]
  104. [ProducesResponseType(StatusCodes.Status404NotFound)]
  105. public ActionResult<UserDto> GetUserById([FromRoute, Required] Guid userId)
  106. {
  107. var user = _userManager.GetUserById(userId);
  108. if (user == null)
  109. {
  110. return NotFound("User not found");
  111. }
  112. var result = _userManager.GetUserDto(user, HttpContext.Connection.RemoteIpAddress.ToString());
  113. return result;
  114. }
  115. /// <summary>
  116. /// Deletes a user.
  117. /// </summary>
  118. /// <param name="userId">The user id.</param>
  119. /// <response code="204">User deleted.</response>
  120. /// <response code="404">User not found.</response>
  121. /// <returns>A <see cref="NoContentResult"/> indicating success or a <see cref="NotFoundResult"/> if the user was not found.</returns>
  122. [HttpDelete("{userId}")]
  123. [Authorize(Policy = Policies.RequiresElevation)]
  124. [ProducesResponseType(StatusCodes.Status204NoContent)]
  125. [ProducesResponseType(StatusCodes.Status404NotFound)]
  126. public ActionResult DeleteUser([FromRoute, Required] Guid userId)
  127. {
  128. var user = _userManager.GetUserById(userId);
  129. _sessionManager.RevokeUserTokens(user.Id, null);
  130. _userManager.DeleteUser(userId);
  131. return NoContent();
  132. }
  133. /// <summary>
  134. /// Authenticates a user.
  135. /// </summary>
  136. /// <param name="userId">The user id.</param>
  137. /// <param name="pw">The password as plain text.</param>
  138. /// <param name="password">The password sha1-hash.</param>
  139. /// <response code="200">User authenticated.</response>
  140. /// <response code="403">Sha1-hashed password only is not allowed.</response>
  141. /// <response code="404">User not found.</response>
  142. /// <returns>A <see cref="Task"/> containing an <see cref="AuthenticationResult"/>.</returns>
  143. [HttpPost("{userId}/Authenticate")]
  144. [ProducesResponseType(StatusCodes.Status200OK)]
  145. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  146. [ProducesResponseType(StatusCodes.Status404NotFound)]
  147. public async Task<ActionResult<AuthenticationResult>> AuthenticateUser(
  148. [FromRoute, Required] Guid userId,
  149. [FromQuery, Required] string? pw,
  150. [FromQuery] string? password)
  151. {
  152. var user = _userManager.GetUserById(userId);
  153. if (user == null)
  154. {
  155. return NotFound("User not found");
  156. }
  157. if (!string.IsNullOrEmpty(password) && string.IsNullOrEmpty(pw))
  158. {
  159. return Forbid("Only sha1 password is not allowed.");
  160. }
  161. // Password should always be null
  162. AuthenticateUserByName request = new AuthenticateUserByName
  163. {
  164. Username = user.Username,
  165. Password = null,
  166. Pw = pw
  167. };
  168. return await AuthenticateUserByName(request).ConfigureAwait(false);
  169. }
  170. /// <summary>
  171. /// Authenticates a user by name.
  172. /// </summary>
  173. /// <param name="request">The <see cref="AuthenticateUserByName"/> request.</param>
  174. /// <response code="200">User authenticated.</response>
  175. /// <returns>A <see cref="Task"/> containing an <see cref="AuthenticationRequest"/> with information about the new session.</returns>
  176. [HttpPost("AuthenticateByName")]
  177. [ProducesResponseType(StatusCodes.Status200OK)]
  178. public async Task<ActionResult<AuthenticationResult>> AuthenticateUserByName([FromBody, Required] AuthenticateUserByName request)
  179. {
  180. var auth = _authContext.GetAuthorizationInfo(Request);
  181. try
  182. {
  183. var result = await _sessionManager.AuthenticateNewSession(new AuthenticationRequest
  184. {
  185. App = auth.Client,
  186. AppVersion = auth.Version,
  187. DeviceId = auth.DeviceId,
  188. DeviceName = auth.Device,
  189. Password = request.Pw,
  190. PasswordSha1 = request.Password,
  191. RemoteEndPoint = HttpContext.Connection.RemoteIpAddress.ToString(),
  192. Username = request.Username
  193. }).ConfigureAwait(false);
  194. return result;
  195. }
  196. catch (SecurityException e)
  197. {
  198. // rethrow adding IP address to message
  199. throw new SecurityException($"[{HttpContext.Connection.RemoteIpAddress}] {e.Message}", e);
  200. }
  201. }
  202. /// <summary>
  203. /// Authenticates a user with quick connect.
  204. /// </summary>
  205. /// <param name="request">The <see cref="QuickConnectDto"/> request.</param>
  206. /// <response code="200">User authenticated.</response>
  207. /// <response code="400">Missing token.</response>
  208. /// <returns>A <see cref="Task"/> containing an <see cref="AuthenticationRequest"/> with information about the new session.</returns>
  209. [HttpPost("AuthenticateWithQuickConnect")]
  210. [ProducesResponseType(StatusCodes.Status200OK)]
  211. public async Task<ActionResult<AuthenticationResult>> AuthenticateWithQuickConnect([FromBody, Required] QuickConnectDto request)
  212. {
  213. var auth = _authContext.GetAuthorizationInfo(Request);
  214. try
  215. {
  216. var authRequest = new AuthenticationRequest
  217. {
  218. App = auth.Client,
  219. AppVersion = auth.Version,
  220. DeviceId = auth.DeviceId,
  221. DeviceName = auth.Device,
  222. };
  223. return await _sessionManager.AuthenticateQuickConnect(
  224. authRequest,
  225. request.Token).ConfigureAwait(false);
  226. }
  227. catch (SecurityException e)
  228. {
  229. // rethrow adding IP address to message
  230. throw new SecurityException($"[{HttpContext.Connection.RemoteIpAddress}] {e.Message}", e);
  231. }
  232. }
  233. /// <summary>
  234. /// Updates a user's password.
  235. /// </summary>
  236. /// <param name="userId">The user id.</param>
  237. /// <param name="request">The <see cref="UpdateUserPassword"/> request.</param>
  238. /// <response code="204">Password successfully reset.</response>
  239. /// <response code="403">User is not allowed to update the password.</response>
  240. /// <response code="404">User not found.</response>
  241. /// <returns>A <see cref="NoContentResult"/> indicating success or a <see cref="ForbidResult"/> or a <see cref="NotFoundResult"/> on failure.</returns>
  242. [HttpPost("{userId}/Password")]
  243. [Authorize(Policy = Policies.DefaultAuthorization)]
  244. [ProducesResponseType(StatusCodes.Status204NoContent)]
  245. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  246. [ProducesResponseType(StatusCodes.Status404NotFound)]
  247. public async Task<ActionResult> UpdateUserPassword(
  248. [FromRoute, Required] Guid userId,
  249. [FromBody] UpdateUserPassword request)
  250. {
  251. if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true))
  252. {
  253. return Forbid("User is not allowed to update the password.");
  254. }
  255. var user = _userManager.GetUserById(userId);
  256. if (user == null)
  257. {
  258. return NotFound("User not found");
  259. }
  260. if (request.ResetPassword)
  261. {
  262. await _userManager.ResetPassword(user).ConfigureAwait(false);
  263. }
  264. else
  265. {
  266. var success = await _userManager.AuthenticateUser(
  267. user.Username,
  268. request.CurrentPw,
  269. request.CurrentPw,
  270. HttpContext.Connection.RemoteIpAddress.ToString(),
  271. false).ConfigureAwait(false);
  272. if (success == null)
  273. {
  274. return Forbid("Invalid user or password entered.");
  275. }
  276. await _userManager.ChangePassword(user, request.NewPw).ConfigureAwait(false);
  277. var currentToken = _authContext.GetAuthorizationInfo(Request).Token;
  278. _sessionManager.RevokeUserTokens(user.Id, currentToken);
  279. }
  280. return NoContent();
  281. }
  282. /// <summary>
  283. /// Updates a user's easy password.
  284. /// </summary>
  285. /// <param name="userId">The user id.</param>
  286. /// <param name="request">The <see cref="UpdateUserEasyPassword"/> request.</param>
  287. /// <response code="204">Password successfully reset.</response>
  288. /// <response code="403">User is not allowed to update the password.</response>
  289. /// <response code="404">User not found.</response>
  290. /// <returns>A <see cref="NoContentResult"/> indicating success or a <see cref="ForbidResult"/> or a <see cref="NotFoundResult"/> on failure.</returns>
  291. [HttpPost("{userId}/EasyPassword")]
  292. [Authorize(Policy = Policies.DefaultAuthorization)]
  293. [ProducesResponseType(StatusCodes.Status204NoContent)]
  294. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  295. [ProducesResponseType(StatusCodes.Status404NotFound)]
  296. public ActionResult UpdateUserEasyPassword(
  297. [FromRoute, Required] Guid userId,
  298. [FromBody] UpdateUserEasyPassword request)
  299. {
  300. if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, true))
  301. {
  302. return Forbid("User is not allowed to update the easy password.");
  303. }
  304. var user = _userManager.GetUserById(userId);
  305. if (user == null)
  306. {
  307. return NotFound("User not found");
  308. }
  309. if (request.ResetPassword)
  310. {
  311. _userManager.ResetEasyPassword(user);
  312. }
  313. else
  314. {
  315. _userManager.ChangeEasyPassword(user, request.NewPw, request.NewPassword);
  316. }
  317. return NoContent();
  318. }
  319. /// <summary>
  320. /// Updates a user.
  321. /// </summary>
  322. /// <param name="userId">The user id.</param>
  323. /// <param name="updateUser">The updated user model.</param>
  324. /// <response code="204">User updated.</response>
  325. /// <response code="400">User information was not supplied.</response>
  326. /// <response code="403">User update forbidden.</response>
  327. /// <returns>A <see cref="NoContentResult"/> indicating success or a <see cref="BadRequestResult"/> or a <see cref="ForbidResult"/> on failure.</returns>
  328. [HttpPost("{userId}")]
  329. [Authorize(Policy = Policies.DefaultAuthorization)]
  330. [ProducesResponseType(StatusCodes.Status204NoContent)]
  331. [ProducesResponseType(StatusCodes.Status400BadRequest)]
  332. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  333. public async Task<ActionResult> UpdateUser(
  334. [FromRoute, Required] Guid userId,
  335. [FromBody] UserDto updateUser)
  336. {
  337. if (updateUser == null)
  338. {
  339. return BadRequest();
  340. }
  341. if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, false))
  342. {
  343. return Forbid("User update not allowed.");
  344. }
  345. var user = _userManager.GetUserById(userId);
  346. if (string.Equals(user.Username, updateUser.Name, StringComparison.Ordinal))
  347. {
  348. await _userManager.UpdateUserAsync(user).ConfigureAwait(false);
  349. _userManager.UpdateConfiguration(user.Id, updateUser.Configuration);
  350. }
  351. else
  352. {
  353. await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
  354. _userManager.UpdateConfiguration(updateUser.Id, updateUser.Configuration);
  355. }
  356. return NoContent();
  357. }
  358. /// <summary>
  359. /// Updates a user policy.
  360. /// </summary>
  361. /// <param name="userId">The user id.</param>
  362. /// <param name="newPolicy">The new user policy.</param>
  363. /// <response code="204">User policy updated.</response>
  364. /// <response code="400">User policy was not supplied.</response>
  365. /// <response code="403">User policy update forbidden.</response>
  366. /// <returns>A <see cref="NoContentResult"/> indicating success or a <see cref="BadRequestResult"/> or a <see cref="ForbidResult"/> on failure..</returns>
  367. [HttpPost("{userId}/Policy")]
  368. [Authorize(Policy = Policies.RequiresElevation)]
  369. [ProducesResponseType(StatusCodes.Status204NoContent)]
  370. [ProducesResponseType(StatusCodes.Status400BadRequest)]
  371. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  372. public ActionResult UpdateUserPolicy(
  373. [FromRoute, Required] Guid userId,
  374. [FromBody] UserPolicy newPolicy)
  375. {
  376. if (newPolicy == null)
  377. {
  378. return BadRequest();
  379. }
  380. var user = _userManager.GetUserById(userId);
  381. // If removing admin access
  382. if (!newPolicy.IsAdministrator && user.HasPermission(PermissionKind.IsAdministrator))
  383. {
  384. if (_userManager.Users.Count(i => i.HasPermission(PermissionKind.IsAdministrator)) == 1)
  385. {
  386. return Forbid("There must be at least one user in the system with administrative access.");
  387. }
  388. }
  389. // If disabling
  390. if (newPolicy.IsDisabled && user.HasPermission(PermissionKind.IsAdministrator))
  391. {
  392. return Forbid("Administrators cannot be disabled.");
  393. }
  394. // If disabling
  395. if (newPolicy.IsDisabled && !user.HasPermission(PermissionKind.IsDisabled))
  396. {
  397. if (_userManager.Users.Count(i => !i.HasPermission(PermissionKind.IsDisabled)) == 1)
  398. {
  399. return Forbid("There must be at least one enabled user in the system.");
  400. }
  401. var currentToken = _authContext.GetAuthorizationInfo(Request).Token;
  402. _sessionManager.RevokeUserTokens(user.Id, currentToken);
  403. }
  404. _userManager.UpdatePolicy(userId, newPolicy);
  405. return NoContent();
  406. }
  407. /// <summary>
  408. /// Updates a user configuration.
  409. /// </summary>
  410. /// <param name="userId">The user id.</param>
  411. /// <param name="userConfig">The new user configuration.</param>
  412. /// <response code="204">User configuration updated.</response>
  413. /// <response code="403">User configuration update forbidden.</response>
  414. /// <returns>A <see cref="NoContentResult"/> indicating success.</returns>
  415. [HttpPost("{userId}/Configuration")]
  416. [Authorize(Policy = Policies.DefaultAuthorization)]
  417. [ProducesResponseType(StatusCodes.Status204NoContent)]
  418. [ProducesResponseType(StatusCodes.Status403Forbidden)]
  419. public ActionResult UpdateUserConfiguration(
  420. [FromRoute, Required] Guid userId,
  421. [FromBody] UserConfiguration userConfig)
  422. {
  423. if (!RequestHelpers.AssertCanUpdateUser(_authContext, HttpContext.Request, userId, false))
  424. {
  425. return Forbid("User configuration update not allowed");
  426. }
  427. _userManager.UpdateConfiguration(userId, userConfig);
  428. return NoContent();
  429. }
  430. /// <summary>
  431. /// Creates a user.
  432. /// </summary>
  433. /// <param name="request">The create user by name request body.</param>
  434. /// <response code="200">User created.</response>
  435. /// <returns>An <see cref="UserDto"/> of the new user.</returns>
  436. [HttpPost("New")]
  437. [Authorize(Policy = Policies.RequiresElevation)]
  438. [ProducesResponseType(StatusCodes.Status200OK)]
  439. public async Task<ActionResult<UserDto>> CreateUserByName([FromBody] CreateUserByName request)
  440. {
  441. var newUser = await _userManager.CreateUserAsync(request.Name).ConfigureAwait(false);
  442. // no need to authenticate password for new user
  443. if (request.Password != null)
  444. {
  445. await _userManager.ChangePassword(newUser, request.Password).ConfigureAwait(false);
  446. }
  447. var result = _userManager.GetUserDto(newUser, HttpContext.Connection.RemoteIpAddress.ToString());
  448. return result;
  449. }
  450. /// <summary>
  451. /// Initiates the forgot password process for a local user.
  452. /// </summary>
  453. /// <param name="enteredUsername">The entered username.</param>
  454. /// <response code="200">Password reset process started.</response>
  455. /// <returns>A <see cref="Task"/> containing a <see cref="ForgotPasswordResult"/>.</returns>
  456. [HttpPost("ForgotPassword")]
  457. [ProducesResponseType(StatusCodes.Status200OK)]
  458. public async Task<ActionResult<ForgotPasswordResult>> ForgotPassword([FromBody] string? enteredUsername)
  459. {
  460. var isLocal = HttpContext.Connection.RemoteIpAddress.Equals(HttpContext.Connection.LocalIpAddress)
  461. || _networkManager.IsInLocalNetwork(HttpContext.Connection.RemoteIpAddress.ToString());
  462. var result = await _userManager.StartForgotPasswordProcess(enteredUsername, isLocal).ConfigureAwait(false);
  463. return result;
  464. }
  465. /// <summary>
  466. /// Redeems a forgot password pin.
  467. /// </summary>
  468. /// <param name="pin">The pin.</param>
  469. /// <response code="200">Pin reset process started.</response>
  470. /// <returns>A <see cref="Task"/> containing a <see cref="PinRedeemResult"/>.</returns>
  471. [HttpPost("ForgotPassword/Pin")]
  472. [ProducesResponseType(StatusCodes.Status200OK)]
  473. public async Task<ActionResult<PinRedeemResult>> ForgotPasswordPin([FromBody] string? pin)
  474. {
  475. var result = await _userManager.RedeemPasswordResetPin(pin).ConfigureAwait(false);
  476. return result;
  477. }
  478. private IEnumerable<UserDto> Get(bool? isHidden, bool? isDisabled, bool filterByDevice, bool filterByNetwork)
  479. {
  480. var users = _userManager.Users;
  481. if (isDisabled.HasValue)
  482. {
  483. users = users.Where(i => i.HasPermission(PermissionKind.IsDisabled) == isDisabled.Value);
  484. }
  485. if (isHidden.HasValue)
  486. {
  487. users = users.Where(i => i.HasPermission(PermissionKind.IsHidden) == isHidden.Value);
  488. }
  489. if (filterByDevice)
  490. {
  491. var deviceId = _authContext.GetAuthorizationInfo(Request).DeviceId;
  492. if (!string.IsNullOrWhiteSpace(deviceId))
  493. {
  494. users = users.Where(i => _deviceManager.CanAccessDevice(i, deviceId));
  495. }
  496. }
  497. if (filterByNetwork)
  498. {
  499. if (!_networkManager.IsInLocalNetwork(HttpContext.Connection.RemoteIpAddress.ToString()))
  500. {
  501. users = users.Where(i => i.HasPermission(PermissionKind.EnableRemoteAccess));
  502. }
  503. }
  504. var result = users
  505. .OrderBy(u => u.Username)
  506. .Select(i => _userManager.GetUserDto(i, HttpContext.Connection.RemoteIpAddress.ToString()));
  507. return result;
  508. }
  509. }
  510. }