Exemple #1
0
 public static bool CanDelete(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication.ID == descriptor.UserInfo.ID)
     {
         return(false);
     }
     return(authentication.Authority == Authority.Admin);
 }
Exemple #2
0
 public static bool CanSendMessage(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication.ID == descriptor.UserInfo.ID)
     {
         return(false);
     }
     return(UserDescriptorUtility.IsOnline(authentication, descriptor));
 }
Exemple #3
0
        public static async Task <bool> BanAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            var dialog = await BanViewModel.CreateInstanceAsync(authentication, descriptor);

            if (dialog != null && await dialog.ShowDialogAsync() == true)
            {
                return(true);
            }
            return(false);
        }
Exemple #4
0
            public When_getting_history_entries()
            {
                _eventStore     = A.Fake <IEventStore>();
                _userDescriptor = A.Fake <IUserDescriptor>();

                A.CallTo(() => _eventStore.Get(AggregateId))
                .Returns(Task.FromResult(CreateTestEvents()));
                A.CallTo(() => _userDescriptor.GetUserDescription(UserId))
                .Returns(User);
            }
 internal void DisplayUserName(IUserDescriptor _UserDescriptor)
 {
     if (_UserDescriptor != null)
     {
         this.m_UserNameLiteral.Text = String.Format("Welcome {0} from {1} !", _UserDescriptor.User, _UserDescriptor.Company);
     }
     else
     {
         this.m_UserNameLiteral.Text = "Information about user is unavailable";
     }
 }
 public static bool IsOnline(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.UserState.HasFlag(UserState.Online));
 }
 public static bool IsBanned(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.BanInfo.ID != string.Empty);
 }
 public static bool IsGuest(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         throw new ArgumentNullException(nameof(authentication));
     }
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(descriptor.UserInfo.Authority == Authority.Guest);
 }
Exemple #9
0
 public static bool CanUnban(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication.ID == descriptor.UserInfo.ID)
     {
         return(false);
     }
     if (authentication.Authority != Authority.Admin)
     {
         return(false);
     }
     return(UserDescriptorUtility.IsBanned(authentication, descriptor) == true);
 }
Exemple #10
0
 public static bool CanKick(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication == null)
     {
         return(false);
     }
     if (authentication.ID == descriptor.UserInfo.ID)
     {
         return(false);
     }
     if (authentication.Authority != Authority.Admin)
     {
         return(false);
     }
     return(UserDescriptorUtility.IsOnline(authentication, descriptor) == true);
 }
Exemple #11
0
        public static async Task <bool> UnbanAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            if (descriptor.Target is IUser user)
            {
                try
                {
                    await user.Dispatcher.InvokeAsync(() => user.Unban(authentication));

                    return(true);
                }
                catch (Exception e)
                {
                    AppMessageBox.ShowError(e);
                    return(false);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #12
0
 public override void SelectObject(object obj)
 {
     this.descriptor = obj as IUserDescriptor;
     if (this.descriptor != null)
     {
         foreach (var item in this.domains)
         {
             item.IsVisible = item.ContainsUser(this.descriptor.UserID);
         }
         this.DisplayName = $"{Resources.Title_UserDomainList} [{this.descriptor.UserID}]";
     }
     else
     {
         foreach (var item in this.domains)
         {
             item.IsVisible = false;
         }
         this.DisplayName = Resources.Title_UserDomainList;
     }
     this.SelectedDomain = null;
     this.NotifyOfPropertyChange(nameof(this.IsVisible));
     this.NotifyOfPropertyChange(nameof(this.SelectedObject));
 }
Exemple #13
0
        public static Task <ChangeUserViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IUser user)
            {
                return(user.Dispatcher.InvokeAsync(() =>
                {
                    return new ChangeUserViewModel(authentication, user);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
Exemple #14
0
 public override void SelectObject(object obj)
 {
     this.Detach();
     this.descriptor = obj as IUserDescriptor;
     this.Attach();
 }
Exemple #15
0
 public static async Task <bool> RenameAsync(Authentication authentication, IUserDescriptor descriptor)
 {
     return(await Task.Run(() => false));
 }
Exemple #16
0
        public static async Task <bool> SendMessageAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            if (descriptor.Target is IUser user)
            {
                var dialog = await SendMessageViewModel.CreateInstanceAsync(authentication, descriptor);

                return(dialog?.ShowDialog() == true);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #17
0
        public static async Task <bool> BanAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            var dialog = await BanViewModel.CreateInstanceAsync(authentication, descriptor);

            return(dialog?.ShowDialog() == true);
        }
Exemple #18
0
        public static Task <MoveUserViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IUser user)
            {
                return(user.Dispatcher.InvokeAsync(() =>
                {
                    var categories = user.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection;
                    var targetPaths = categories.Select(item => item.Path).ToArray();
                    return new MoveUserViewModel(authentication, user, targetPaths);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
Exemple #19
0
 public static bool CanRename(Authentication authentication, IUserDescriptor descriptor)
 {
     return(false);
 }
Exemple #20
0
 public HistoryService(IEventStore eventStore, IUserDescriptor userDescriptor)
 {
     _eventStore     = eventStore;
     _userDescriptor = userDescriptor;
 }
Exemple #21
0
 public static bool CanRename(Authentication _1, IUserDescriptor _2)
 {
     return(false);
 }
 public UserDescriptor(Authentication authentication, IUserDescriptor descriptor, bool isSubscriptable, object owner)
     : base(authentication, descriptor.Target, descriptor, isSubscriptable)
 {
     this.user  = descriptor.Target;
     this.Owner = owner ?? this;
 }
Exemple #23
0
 public static bool CanMove(Authentication authentication, IUserDescriptor _)
 {
     return(authentication.Authority == Authority.Admin);
 }
        public static Task <SendMessageViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is IUser user)
            {
                return(user.Dispatcher.InvokeAsync(() =>
                {
                    return new SendMessageViewModel(authentication, user);
                }));
            }
            else
            {
                throw new ArgumentException("ServiceProvider does not provide IUserContext", nameof(descriptor));
            }
        }
Exemple #25
0
 public static bool CanChange(Authentication authentication, IUserDescriptor descriptor)
 {
     return(authentication.Authority == Authority.Admin);
 }