コード例 #1
0
        private async Task <JsonResult> SaveImpersonationTokenAndGetTargetUrl(int?tenantId, long userId, bool isBackToImpersonator)
        {
            //Create a cache item
            var cacheItem = new ImpersonationCacheItem(
                tenantId,
                userId,
                isBackToImpersonator
                );

            if (!isBackToImpersonator)
            {
                cacheItem.ImpersonatorTenantId = AbpSession.TenantId;
                cacheItem.ImpersonatorUserId   = AbpSession.GetUserId();
            }

            //Create a random token and save to the cache
            var tokenId = Guid.NewGuid().ToString();
            await _cacheManager
            .GetImpersonationCache()
            .SetAsync(tokenId, cacheItem, TimeSpan.FromMinutes(1));

            //Find tenancy name
            string tenancyName = null;

            if (tenantId.HasValue)
            {
                tenancyName = (await _tenantManager.GetByIdAsync(tenantId.Value)).TenancyName;
            }

            //Create target URL
            var targetUrl = _webUrlService.GetSiteRootAddress(tenancyName) + "Account/ImpersonateSignIn?tokenId=" + tokenId;

            return(Json(new AjaxResponse {
                TargetUrl = targetUrl
            }));
        }
コード例 #2
0
        public PartialViewResult Preview(string token, string mediaID, string mpId, string messageType)
        {
            //var head =  "http://yiliscrm3.mgcc.com.cn";

            var head  = _webUrlService.GetSiteRootAddress();
            var reurl = Base64Helper.EncodeBase64(head + _matialFileService.PreviewUrl + $"?mediaID={mediaID},{mpId},{messageType}");
            var url   = head + _matialFileService.Auth2Url;

            ViewBag.Url         = url;
            ViewBag.Token       = token;
            ViewBag.Reurl       = reurl;
            ViewBag.MediaID     = mediaID;
            ViewBag.MpId        = mpId;
            ViewBag.MessageType = messageType;
            return(PartialView("_Preview"));
        }
コード例 #3
0
        public async Task <ActionResult> Logout()
        {
            var tenancyName = "";

            if (AbpSession.TenantId.HasValue)
            {
                var tenant = await _tenantManager.GetByIdAsync(AbpSession.GetTenantId());

                tenancyName = tenant.TenancyName;
            }

            var websiteAddress = _webUrlService.GetSiteRootAddress(tenancyName);
            var serverAddress  = _webUrlService.GetServerRootAddress(tenancyName);

            await _signInManager.SignOutAsync();

            return(Redirect(serverAddress.EnsureEndsWith('/') + "account/logout?returnUrl=" + websiteAddress));
        }
コード例 #4
0
        public async Task <PartialViewResult> BindingOpenID(int id)
        {
            ViewBag.ImageUrl = "";
            if (id != 0)
            {
                var head   = _webUrlService.GetSiteRootAddress();
                var output = await _CustomerServiceOnlineAppService.Get(new EntityDto <int>(id));

                var access = await _mpAccountAppService.Get(new EntityDto <int> {
                    Id = output.MpID
                });

                var reurl = Base64Helper.EncodeBase64(head + $"MpApi/BindOpenID?id={id}");
                ViewBag.BindingUrl = head + _matialFileService.Auth2Url;
                ViewBag.Token      = access.TaskAccessToken;
                ViewBag.Reurl      = reurl;
            }
            return(PartialView("_BindingOpenID"));
        }
コード例 #5
0
        public virtual async Task <ActionResult> Register(RegisterTenantInput model)
        {
            try
            {
                if (UseCaptchaOnRegistration())
                {
                    model.CaptchaResponse = HttpContext.Request.Form[RecaptchaValidator.RecaptchaResponseKey];
                }

                var result = await _tenantRegistrationAppService.RegisterTenant(model);

                CurrentUnitOfWork.SetTenantId(result.TenantId);

                var user = await _userManager.FindByNameAsync(AbpUserBase.AdminUserName);

                //Directly login if possible
                if (result.IsTenantActive && result.IsActive && !result.IsEmailConfirmationRequired &&
                    !_webUrlService.SupportsTenancyNameInUrl)
                {
                    var loginResult = await GetLoginResultAsync(user.UserName, model.AdminPassword, model.TenancyName);

                    if (loginResult.Result == AbpLoginResultType.Success)
                    {
                        await _signInManager.SignOutAsync();

                        await _signInManager.SignInAsync(loginResult.Identity, false);

                        SetTenantIdCookie(result.TenantId);

                        return(Redirect(Url.Action("Index", "Home", new { area = "AppAreaName" })));
                    }

                    Logger.Warn("New registered user could not be login. This should not be normally. login result: " + loginResult.Result);
                }

                //Show result page
                var resultModel = ObjectMapper.Map <TenantRegisterResultViewModel>(result);

                resultModel.TenantLoginAddress = _webUrlService.SupportsTenancyNameInUrl
                    ? _webUrlService.GetSiteRootAddress(model.TenancyName).EnsureEndsWith('/') + "Account/Login"
                    : "";

                return(View("RegisterResult", resultModel));
            }
            catch (UserFriendlyException ex)
            {
                ViewBag.UseCaptcha   = UseCaptchaOnRegistration();
                ViewBag.ErrorMessage = ex.Message;

                var viewModel = new TenantRegisterViewModel
                {
                    PasswordComplexitySetting = await _passwordComplexitySettingStore.GetSettingsAsync(),
                    EditionId             = model.EditionId,
                    SubscriptionStartType = model.SubscriptionStartType,
                    EditionPaymentType    = EditionPaymentType.NewRegistration,
                    Gateway   = model.Gateway,
                    PaymentId = model.PaymentId
                };

                if (model.EditionId.HasValue)
                {
                    viewModel.Edition = await _tenantRegistrationAppService.GetEdition(model.EditionId.Value);

                    viewModel.EditionId = model.EditionId.Value;
                }

                return(View("Register", viewModel));
            }
        }
コード例 #6
0
        public CustomMessageHandler(Stream inputStream, PostModel postModel, ILogger logger
                                    , ICacheManager cacheManager, IMpAccountAppService mpAccountAppService, int _mpId
                                    , IMpEventAppService mpEventAppService, IMpMediaVideoAppService mpMediaVideoAppService
                                    , IMpSelfArticleAppService mpSelfArticleAppService
                                    , IMpSelfArticleGroupAppService mpSelfArticleGroupAppService
                                    , IMpSelfArticleGroupItemAppService mpSelfArticleGroupItemAppService
                                    , IMpEventRequestMsgLogAppService mpEventRequestMsgLogAppService
                                    , IMpKeyWordReplyAppService mpKeyWordReplyAppService
                                    , IMpEventClickViewLogAppService mpEventClickViewLogAppService
                                    , IMpMenuAppService mpMenuAppService
                                    , IMpMessageAppService mpMessageAppService
                                    , IAccessTokenContainer accessTokenContainer
                                    , IMpFanAppService mpFanAppService
                                    , IMpEventScanLogAppService mpEventScanLogAppService
                                    , ICustomerServiceResponseTextAppService customerServiceResponseTextAppService
                                    , IMpUserMemberAppService mpUserMemberAppService
                                    , MpAccountDto account
                                    , IMpChannelAppService mpChannelAppService
                                    , IIocResolver iocResolver
                                    , IMatialFileService matialFileService
                                    , IWebUrlService webUrlService
                                    , IYiliBabyClubInterfaceService yiliBabyClubInterfaceService
                                    , int maxRecordCount = 0)
            : base(inputStream, postModel, maxRecordCount)
        {
            mpId                                   = _mpId;
            _cacheManager                          = cacheManager;
            _logger                                = logger;
            _accessTokenContainer                  = accessTokenContainer;
            _mpAccountAppService                   = mpAccountAppService;
            _mpEventAppService                     = mpEventAppService;
            _mpEventClickViewLogAppService         = mpEventClickViewLogAppService;
            _mpEventRequestMsgLogAppService        = mpEventRequestMsgLogAppService;
            _mpEventScanLogAppService              = mpEventScanLogAppService;
            _mpFanAppService                       = mpFanAppService;
            _mpKeyWordReplyAppService              = mpKeyWordReplyAppService;
            _mpMediaVideoAppService                = mpMediaVideoAppService;
            _mpMenuAppService                      = mpMenuAppService;
            _mpMessageAppService                   = mpMessageAppService;
            _mpSelfArticleGroupItemAppService      = mpSelfArticleGroupItemAppService;
            _mpSelfArticleGroupAppService          = mpSelfArticleGroupAppService;
            _mpSelfArticleAppService               = mpSelfArticleAppService;
            WeixinContext.ExpireMinutes            = 3;
            _customerServiceResponseTextAppService = customerServiceResponseTextAppService;
            _mpUserMemberAppService                = mpUserMemberAppService;
            _iocResolver                           = iocResolver;
            _account                               = account;
            _matialFileService                     = matialFileService;
            _webUrlService                         = webUrlService;
            _mpChannelAppService                   = mpChannelAppService;
            _yiliBabyClubInterfaceService          = yiliBabyClubInterfaceService;
            domain                                 = _webUrlService.GetSiteRootAddress();
            if (!string.IsNullOrEmpty(postModel.AppId))
            {
                appId = postModel.AppId;//通过第三方开放平台发送过来的请求
            }

            //在指定条件下,不使用消息去重
            base.OmitRepeatedMessageFunc = requestMessage =>
            {
                var textRequestMessage = requestMessage as RequestMessageText;
                if (textRequestMessage != null && textRequestMessage.Content == "容错")
                {
                    return(false);
                }
                return(true);
            };
        }
コード例 #7
0
        public string CreatePasswordResetUrlFormat()
        {
            var resetLink = WebUrlService.GetSiteRootAddress().EnsureEndsWith('/') + PasswordResetRoute + "?userId={userId}&resetCode={resetCode}";

            return(resetLink);
        }