Пример #1
0
        public void Test_GetIp_XForwardTrue()
        {
            const string expectedIp = "1.2.3.4";
            const string otherIp    = "5.6.7.8";

            var ctx = new DefaultHttpContext();

            ctx.Request.Headers["X-Forwarded-For"]      = expectedIp;
            ctx.Request.Headers["HTTP-X-Forwarded-For"] = otherIp;
            ctx.Request.Headers["REMOTE_ADDR"]          = otherIp;

            _accessorMock.Setup(_ => _.HttpContext).Returns(ctx);

            var ip = _service.GetRequestIp();

            Assert.AreEqual(expectedIp, ip);
        }
Пример #2
0
        public async Task <EmailMessage> SendAccountUnlockEmailAsync(IdentityUser user, string recoveryToken)
        {
            await Task.Yield();

            var message = new EmailMessage
            {
                To          = user.Email,
                Subject     = "SecureWebApp: User account locked",
                HtmlMessage = await GetEmailTemplateAsync(Templates.AccountUnlock, user.UserName, _ipAddressService.GetRequestIp(), user.Id, recoveryToken)
            };

            // Send the mail asyncronously in the background
            _ = SendEmailAsync(message);

            // Immediately return the generated message
            return(message);
        }