Exemplo n.º 1
0
 public static bool CanSendMessage(Authentication authentication, IUserDescriptor descriptor)
 {
     if (authentication.ID == descriptor.UserInfo.ID)
     {
         return(false);
     }
     return(UserDescriptorUtility.IsOnline(authentication, descriptor));
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Authenticator.Current == null)
            {
                return(value);
            }

            if (parameter == null)
            {
                parameter = this.PropertyName;
            }

            if (value != null && parameter is string propertyName)
            {
                if (value is IUserDescriptor descriptor)
                {
                    if (propertyName == IsOnline)
                    {
                        return(UserDescriptorUtility.IsOnline(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsBanned)
                    {
                        return(UserDescriptorUtility.IsBanned(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsAdmin)
                    {
                        return(UserDescriptorUtility.IsAdmin(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsMember)
                    {
                        return(UserDescriptorUtility.IsMember(Authenticator.Current, descriptor));
                    }
                    else if (propertyName == IsGuest)
                    {
                        return(UserDescriptorUtility.IsGuest(Authenticator.Current, descriptor));
                    }
                }
                else
                {
                    var prop = value.GetType().GetProperty(propertyName);
                    if (prop != null)
                    {
                        return(prop.GetValue(value));
                    }
                }
            }
            return(value);
        }
Exemplo n.º 4
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);
 }