diff --git a/Yavsc/ApiControllers/AccountController.cs b/Yavsc/ApiControllers/AccountController.cs index 68a6c912..6a154684 100644 --- a/Yavsc/ApiControllers/AccountController.cs +++ b/Yavsc/ApiControllers/AccountController.cs @@ -13,6 +13,7 @@ namespace Yavsc.WebApi.Controllers using Models.Auth; using Yavsc.Helpers; using System; + using System.Linq; [Authorize(),Route("~/api/account"),Obsolete] public class ApiAccountController : Controller @@ -141,6 +142,24 @@ namespace Yavsc.WebApi.Controllers return Ok(user); } + [HttpGet("~/api/myip"),Authorize] + public async Task MyIp () + { + string ip = null; + + ip = Request.Headers["X-Forwarded-For"]; + + if (string.IsNullOrEmpty(ip)) { + ip = Request.Host.Value; + } else { // Using X-Forwarded-For last address + ip = ip.Split(',') + .Last() + .Trim(); + } + + return Ok(ip); + } + /// /// Actually only updates the user's name. ///