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.
|
|
|
|
using Connected.Security.Identity;
|
|
|
|
|
|
|
|
|
|
namespace Connected.Security;
|
|
|
|
|
|
|
|
|
|
public static class SecurityExtensions
|
|
|
|
|
{
|
|
|
|
|
public static string DisplayName(this IUser user)
|
|
|
|
|
{
|
|
|
|
|
if (user is null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
string fn = FullName(user.FirstName, user.LastName);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fn))
|
|
|
|
|
return fn;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(user.LoginName))
|
|
|
|
|
return user.LoginName;
|
|
|
|
|
|
|
|
|
|
if (user.Email?.Contains('@') == true)
|
|
|
|
|
return user.Email[..user.Email.IndexOf('@')];
|
|
|
|
|
|
|
|
|
|
return user.Id.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string FullName(string firstName, string lastName)
|
|
|
|
|
{
|
|
|
|
|
return $"{firstName} {lastName}".Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|