/// <summary>
        /// Gets the name of the default thumbnail profile.
        /// </summary>
        /// <typeparam name="TLibrary">The type of the library.</typeparam>
        /// <returns>The name of the default thumbnail profile.</returns>
        protected static string DefaultThumbnailProfileName <TLibrary>()
            where TLibrary : Library
        {
            ConfigElementDictionary <string, ThumbnailProfileConfigElement> profiles;
            Type libraryType = typeof(TLibrary);

            if (libraryType == typeof(Album))
            {
                profiles = Config.Get <LibrariesConfig>().Images.Thumbnails.Profiles;
            }
            else if (libraryType == typeof(VideoLibrary))
            {
                return(VideoSystemThumbnailName);
            }
            else
            {
                return(null);
            }

            var defaultProfile = profiles.Values.FirstOrDefault(p => p.IsDefault) ?? profiles.Values.FirstOrDefault(p => p.Name == "thumbnail") ?? profiles.Values.FirstOrDefault();

            if (defaultProfile != null)
            {
                return(defaultProfile.Name);
            }
            else
            {
                return(null);
            }
        }
        public virtual LoginFormViewModel Authenticate(LoginFormViewModel input, HttpContextBase context)
        {
            input.LoginError = false;

            if (Config.Get <SecurityConfig>().AuthenticationMode == SecConfig.AuthenticationMode.Claims)
            {
                var owinContext         = context.Request.GetOwinContext();
                var challengeProperties = ChallengeProperties.ForLocalUser(input.UserName, input.Password, this.MembershipProvider, input.RememberMe, context.Request.Url.ToString());
                challengeProperties.RedirectUri = this.GetReturnURL(context);
                owinContext.Authentication.Challenge(challengeProperties, ClaimsManager.CurrentAuthenticationModule.STSAuthenticationType);
            }
            else
            {
                User user;
                UserLoggingReason result = SecurityManager.AuthenticateUser(
                    this.MembershipProvider,
                    input.UserName,
                    input.Password,
                    input.RememberMe,
                    out user);

                if (result != UserLoggingReason.Success)
                {
                    input.LoginError = true;
                }
                else
                {
                    input.RedirectUrlAfterLogin = this.GetReturnURL(context);
                }
            }

            return(input);
        }
Exemple #3
0
        private ThumbnailProfileConfigElement DefaultAlbumThumbnailProfile(string thumbnailName)
        {
            if (!string.IsNullOrWhiteSpace(thumbnailName))
            {
                var profiles = Config.Get <LibrariesConfig>().Images.Thumbnails.Profiles;

                if (profiles.ContainsKey(thumbnailName))
                {
                    var thumbnailProfile = profiles[thumbnailName];

                    return(thumbnailProfile);
                }
            }

            return(null);
        }
Exemple #4
0
        /// <summary>
        /// Gets the selected size URL.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <returns></returns>
        protected virtual string GetSelectedSizeUrl(SfImage image, ImageSizeModel sizeModel)
        {
            if (image.Id == Guid.Empty)
            {
                return(string.Empty);
            }

            string imageUrl;
            var    urlAsAbsolute = Config.Get <SystemConfig>().SiteUrlSettings.GenerateAbsoluteUrls;

            if (sizeModel.DisplayMode == ImageDisplayMode.Thumbnail && !string.IsNullOrWhiteSpace(sizeModel.Thumbnail.Name))
            {
                imageUrl = image.ResolveThumbnailUrl(sizeModel.Thumbnail.Name, urlAsAbsolute);
            }
            else
            {
                var originalImageUrl = image.ResolveMediaUrl(urlAsAbsolute);
                imageUrl = originalImageUrl;
            }

            return(imageUrl);
        }
        /// <summary>
        /// Gets the thumbnail URL for the selected size.
        /// </summary>
        /// <param name="video">The video.</param>
        /// <param name="sizeModel">The size model.</param>
        /// <returns></returns>
        protected virtual string GetSelectedSizeUrl(SfVideo video, ImageSizeModel sizeModel)
        {
            if (video.Id == Guid.Empty)
            {
                return(string.Empty);
            }

            var urlAsAbsolute = Config.Get <SystemConfig>().SiteUrlSettings.GenerateAbsoluteUrls;

            string videoThumbnailUrl;

            if (sizeModel.DisplayMode == ImageDisplayMode.Thumbnail && !string.IsNullOrWhiteSpace(sizeModel.Thumbnail.Name))
            {
                videoThumbnailUrl = video.ResolveThumbnailUrl(sizeModel.Thumbnail.Name, urlAsAbsolute);
            }
            else
            {
                videoThumbnailUrl = video.ResolveThumbnailUrl("0", urlAsAbsolute);
            }

            return(videoThumbnailUrl);
        }