mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Squidex.Infrastructure.Reflection;
|
|
using Squidex.Shared.Users;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.Users.Models
|
|
{
|
|
public sealed class UserDto
|
|
{
|
|
/// <summary>
|
|
/// The id of the user.
|
|
/// </summary>
|
|
[Required]
|
|
public string Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// The email of the user. Unique value.
|
|
/// </summary>
|
|
[Required]
|
|
public string Email { get; set; }
|
|
|
|
/// <summary>
|
|
/// The display name (usually first name and last name) of the user.
|
|
/// </summary>
|
|
[Required]
|
|
public string DisplayName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Determines if the user is locked.
|
|
/// </summary>
|
|
[Required]
|
|
public bool IsLocked { get; set; }
|
|
|
|
/// <summary>
|
|
/// Additional permissions for the user.
|
|
/// </summary>
|
|
[Required]
|
|
public string[] Permissions { get; set; }
|
|
|
|
public static UserDto FromUser(IUser user)
|
|
{
|
|
var permissions = user.Permissions().ToIds().ToArray();
|
|
|
|
return SimpleMapper.Map(user, new UserDto { DisplayName = user.DisplayName(), Permissions = permissions });
|
|
}
|
|
}
|
|
}
|
|
|