} // 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
private readonly List <WeakReference <PrivateUserDataContext> > currentContexts = new List <WeakReference <PrivateUserDataContext> >(); // current active user contexts #region -- Ctor/Dtor/Idle ------------------------------------------------- public PrivateUserData(PpsApplication application, long userId, PpsUserIdentity userIdentity) { this.application = application ?? throw new ArgumentNullException(nameof(application)); this.userId = userId; if (userId == sysUserId) // mark system user { if (userIdentity != null) { throw new ArgumentException("UserIdentity must be null.", nameof(userIdentity)); } userIdentity = localIdentity = PpsUserIdentity.System; this[UserContextFullName] = "System"; } this.userIdentity = userIdentity; log = LoggerProxy.Create(application, userIdentity.Name); application.Server.RegisterUser(this); // register the user in http-server } // ctor
} // 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