Beispiel #1
0
        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;
            }));
        }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 public void SetLoggedUser(User user)
 {
     LoggedUser = new ServerOnlyUserWithPermissionsContract(user, ContentLanguagePreference.Default);
 }
Beispiel #4
0
 public FakePermissionContext(ServerOnlyUserWithPermissionsContract loggedUser)
 {
     LoggedUser = loggedUser;
 }
Beispiel #5
0
 protected abstract void SetPersistedValue(ServerOnlyUserWithPermissionsContract user, T val);
Beispiel #6
0
 protected abstract T GetPersistedValue(ServerOnlyUserWithPermissionsContract permissionContext);
Beispiel #7
0
 public VocaDbPrincipal(IIdentity identity, ServerOnlyUserWithPermissionsContract user)
     : base(identity, new string[] { })
 {
     _user = user;
 }
Beispiel #8
0
 protected override void SetPersistedValue(ServerOnlyUserWithPermissionsContract user, string val)
 {
     user.Language = val;
 }
Beispiel #9
0
 protected override string GetPersistedValue(ServerOnlyUserWithPermissionsContract permissionContext) => permissionContext.Language;