예제 #1
0
        private bool TryAuthorize <T>(ChunkedRequestHelper <T> request)
        {
            if (request.Type(InstanceCrypto) == ChunkedRequestType.Initiate)
            {
                TenantManager.SetCurrentTenant(request.TenantId);
                SecurityContext.AuthenticateMeWithoutCookie(AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, request.AuthKey(InstanceCrypto)));
                var cultureInfo = request.CultureInfo(SetupInfo);
                if (cultureInfo != null)
                {
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }
                return(true);
            }

            if (!string.IsNullOrEmpty(request.UploadId))
            {
                var uploadSession = ChunkedUploadSessionHolder.GetSession <T>(request.UploadId);
                if (uploadSession != null)
                {
                    TenantManager.SetCurrentTenant(uploadSession.TenantId);
                    SecurityContext.AuthenticateMeWithoutCookie(AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, uploadSession.UserId));
                    var culture = SetupInfo.GetPersonalCulture(uploadSession.CultureName).Value;
                    if (culture != null)
                    {
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        private bool TryAuthorize <T>(ChunkedRequestHelper <T> request)
        {
            if (request.Type(InstanceCrypto) == ChunkedRequestType.Initiate)
            {
                TenantManager.SetCurrentTenant(request.TenantId);
                SecurityContext.AuthenticateMe(AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, request.AuthKey(InstanceCrypto)));
                var cultureInfo = request.CultureInfo(SetupInfo);
                if (cultureInfo != null)
                {
                    Thread.CurrentThread.CurrentUICulture = cultureInfo;
                }
                return(true);
            }

            if (!string.IsNullOrEmpty(request.UploadId))
            {
                var uploadSession = ChunkedUploadSessionHolder.GetSession(request.UploadId);
                if (uploadSession != null)
                {
                    TenantManager.SetCurrentTenant(uploadSession.TenantId);
                    SecurityContext.AuthenticateMe(AuthManager.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, uploadSession.UserId));
                    var culture = SetupInfo.EnabledCulturesPersonal.Find(c => string.Equals(c.Name, uploadSession.CultureName, StringComparison.InvariantCultureIgnoreCase));
                    if (culture != null)
                    {
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }
                    return(true);
                }
            }

            return(false);
        }
        private static bool TryAuthorize(ChunkedRequestHelper request)
        {
            if (request.Type == ChunkedRequestType.Initiate)
            {
                CoreContext.TenantManager.SetCurrentTenant(request.TenantId);
                SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(request.AuthKey));
                if (request.CultureInfo != null)
                {
                    Thread.CurrentThread.CurrentUICulture = request.CultureInfo;
                }
                return(true);
            }

            if (!string.IsNullOrEmpty(request.UploadId))
            {
                var uploadSession = ChunkedUploadSessionHolder.GetSession(request.UploadId);
                if (uploadSession != null)
                {
                    CoreContext.TenantManager.SetCurrentTenant(uploadSession.TenantId);
                    SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(uploadSession.UserId));
                    var culture = SetupInfo.GetPersonalCulture(uploadSession.CultureName).Value;
                    if (culture != null)
                    {
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        public async Task Invoke(HttpContext context)
        {
            var uploadSession = ChunkedUploadSessionHolder.GetSession(context.Request.Query["uid"]);

            if (uploadSession as ChunkedUploadSession <int> != null)
            {
                await Invoke <int>(context);

                return;
            }

            await Invoke <string>(context);
        }
예제 #5
0
 public async Task Invoke(HttpContext context)
 {
     try
     {
         var uploadSession = ChunkedUploadSessionHolder.GetSession <int>(context.Request.Query["uid"]);
         if (uploadSession != null)
         {
             await Invoke <int>(context);
         }
     }
     catch (Exception)
     {
         await Invoke <string>(context);
     }
 }
예제 #6
0
        private static bool TryAuthorize(ChunkedRequestHelper request)
        {
            if (request.Type == ChunkedRequestType.Initiate)
            {
                CoreContext.TenantManager.SetCurrentTenant(request.TenantId);
                SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(request.AuthKey));
                return(true);
            }

            if (!string.IsNullOrEmpty(request.UploadId))
            {
                var uploadSession = ChunkedUploadSessionHolder.GetSession(request.UploadId);
                if (uploadSession != null)
                {
                    CoreContext.TenantManager.SetCurrentTenant(uploadSession.TenantId);
                    SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(uploadSession.UserId));
                    return(true);
                }
            }

            return(false);
        }
예제 #7
0
        private static bool TryAuthorize(ChunkedRequestHelper request)
        {
            if (request.Type == ChunkedRequestType.Initiate)
            {
                CoreContext.TenantManager.SetCurrentTenant(request.TenantId);
                SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(request.AuthKey));
                Thread.CurrentThread.CurrentUICulture = request.CultureInfo;
                return(true);
            }

            if (!string.IsNullOrEmpty(request.UploadId))
            {
                var uploadSession = ChunkedUploadSessionHolder.GetSession(request.UploadId);
                if (uploadSession != null)
                {
                    CoreContext.TenantManager.SetCurrentTenant(uploadSession.TenantId);
                    SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(uploadSession.UserId));
                    Thread.CurrentThread.CurrentUICulture = SetupInfo.EnabledCulturesPersonal.Find(c => String.Equals(c.Name, uploadSession.CultureName, StringComparison.InvariantCultureIgnoreCase));
                    return(true);
                }
            }

            return(false);
        }