namespace NTP.Application.Auth; /// /// The user name typed on the sign-in page. Users type just their login; the legacy "DOMAIN.login" spelling (for example ASEZA.50034) /// is still accepted, in which case the domain is taken from it instead of being looked up. /// public static class LoginName { /// /// Domain is null when only a login was typed. Login is lower case and trimmed. A name with exactly two dot-separated /// parts is "DOMAIN.login"; anything else is one login (no login in NTPUSERS contains a dot). /// public static (string? Domain, string Login) Parse(string userName) { var text = (userName ?? string.Empty).Trim(); var parts = text.Split('.', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); return parts.Length == 2 ? (parts[0], parts[1].ToLowerInvariant()) : (null, text.ToLowerInvariant()); } }