} // func DemandToken #endregion #region -- UpdateData ----------------------------------------------------- internal void UpdateData(IDataRow r, bool force) { // check if we need a reload var loginVersion = r.GetProperty("LoginVersion", 0); if (!force && loginVersion == currentVersion) { return; } // currently service is for local stuff localIdentity = application.systemUser.userIdentity; currentVersion = loginVersion; // update optional values SetMemberValue(UserContextFullName, r.GetProperty("Name", userIdentity.Name)); if (r.TryGetProperty <long>(UserContextKtKtId, out var ktktId)) { SetMemberValue(UserContextKtKtId, ktktId); } if (r.TryGetProperty <long>(UserContextPersId, out var persId)) { SetMemberValue(UserContextPersId, persId); } if (r.TryGetProperty <string>(UserContextInitials, out var initials)) { SetMemberValue(UserContextInitials, initials); } if (r.TryGetProperty <int>(UserContextIdenticon, out var identicon)) { SetMemberValue(UserContextIdenticon, identicon); } // update parameter set from database, use only members foreach (var kv in FromLson(r.GetProperty("Cfg", "{}")).Members) { SetMemberValue(kv.Key, kv.Value); } securityTokens = application.Server.BuildSecurityTokens(r.GetProperty("Security", String.Empty), SecurityUser); } // proc UpdateData
} // proc UpdateData public static PpsUserIdentity CreateUserIdentity(IDataRow r) { string GetString(string fieldName) => r.GetProperty(fieldName, null) ?? throw new ArgumentNullException($"{fieldName} is null."); // create the user var userType = r.GetProperty("LoginType", (string)null); if (userType == "U") // windows login { return(PpsUserIdentity.CreateIntegratedIdentity(GetString("Login"))); } else if (userType == "S") // sql login { return(PpsUserIdentity.CreateBasicIdentity( GetString("Login"), (byte[])r["LoginHash", true] )); } else { throw new ArgumentException($"Unsupported login type '{userType}'."); } } // func CreateUserIdentity