Headless CMS and Content Managment Hub
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.3 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Identity;
using Squidex.Infrastructure;
using Squidex.Shared.Users;
namespace Squidex.Domain.Users
{
public sealed class UserWithClaims : IUser
{
public IdentityUser Identity { get; }
public List<Claim> Claims { get; }
public string Id
{
get { return Identity.Id; }
}
public string Email
{
get { return Identity.Email; }
}
public bool IsLocked
{
get { return Identity.LockoutEnd > DateTime.UtcNow; }
}
IReadOnlyList<Claim> IUser.Claims
{
get { return Claims; }
}
public UserWithClaims(IdentityUser user, IEnumerable<Claim> claims)
{
Guard.NotNull(user);
Guard.NotNull(claims);
Identity = user;
Claims = claims.ToList();
}
}
}