public ServerOnlyUserWithPermissionsContract GetUserByName(string name, bool skipMessages) { return(HandleQuery(session => { var user = session.Query <User>().FirstOrDefault(u => u.Name.Equals(name)); if (user == null) { return null; } var contract = new ServerOnlyUserWithPermissionsContract(user, LanguagePreference); if (!skipMessages) { contract.UnreadMessagesCount = session.Query <UserMessage>() .Where(m => m.User.Id == user.Id) .WhereIsUnread(true) .WhereInboxIs(UserInboxType.Nothing, true) .Count(); } return contract; })); }
public UserEdit(ServerOnlyUserWithPermissionsContract contract) : this() { Active = contract.Active; Email = contract.Email; GroupId = contract.GroupId; Id = contract.Id; Name = OldName = contract.Name; OwnedArtists = contract.OwnedArtistEntries; Permissions = PermissionToken.All .Select(p => new PermissionFlagEntry(p, contract.AdditionalPermissions.Contains(p), contract.EffectivePermissions.Contains(p))).ToArray(); Poisoned = contract.Poisoned; Supporter = contract.Supporter; }
public void SetLoggedUser(User user) { LoggedUser = new ServerOnlyUserWithPermissionsContract(user, ContentLanguagePreference.Default); }
public FakePermissionContext(ServerOnlyUserWithPermissionsContract loggedUser) { LoggedUser = loggedUser; }
protected abstract void SetPersistedValue(ServerOnlyUserWithPermissionsContract user, T val);
protected abstract T GetPersistedValue(ServerOnlyUserWithPermissionsContract permissionContext);
public VocaDbPrincipal(IIdentity identity, ServerOnlyUserWithPermissionsContract user) : base(identity, new string[] { }) { _user = user; }
protected override void SetPersistedValue(ServerOnlyUserWithPermissionsContract user, string val) { user.Language = val; }
protected override string GetPersistedValue(ServerOnlyUserWithPermissionsContract permissionContext) => permissionContext.Language;