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.
46 lines
1.5 KiB
46 lines
1.5 KiB
// ==========================================================================
|
|
// WrappedIdentityUser.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Identity.MongoDB;
|
|
using Squidex.Shared.Users;
|
|
|
|
namespace Squidex.Domain.Users.MongoDb
|
|
{
|
|
public sealed class WrappedIdentityUser : IdentityUser, IUser
|
|
{
|
|
public bool IsLocked
|
|
{
|
|
get { return LockoutEndDateUtc != null && LockoutEndDateUtc.Value > DateTime.UtcNow; }
|
|
}
|
|
|
|
IReadOnlyList<Claim> IUser.Claims
|
|
{
|
|
get { return Claims.Select(x => new Claim(x.Type, x.Value)).ToList(); }
|
|
}
|
|
|
|
IReadOnlyList<ExternalLogin> IUser.Logins
|
|
{
|
|
get { return Logins.Select(x => new ExternalLogin(x.LoginProvider, x.ProviderKey, x.ProviderDisplayName)).ToList(); }
|
|
}
|
|
|
|
public void UpdateEmail(string email)
|
|
{
|
|
Email = UserName = email;
|
|
}
|
|
|
|
public void SetClaim(string type, string value)
|
|
{
|
|
Claims.RemoveAll(x => string.Equals(x.Type, type, StringComparison.OrdinalIgnoreCase));
|
|
Claims.Add(new IdentityUserClaim { Type = type, Value = value });
|
|
}
|
|
}
|
|
}
|
|
|