public static bool CanSendMessage(Authentication authentication, IUserDescriptor descriptor) { if (authentication.ID == descriptor.UserInfo.ID) { return(false); } return(UserDescriptorUtility.IsOnline(authentication, descriptor)); }
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); }
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); }
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); }