public IHttpActionResult Login([FromBody] LoginModel model)
    {
        try
        {
            //Inject ldap information collected by browser
            if (System.Web.HttpContext.Current != null &&
                System.Web.HttpContext.Current.Request != null &&
                System.Web.HttpContext.Current.Request.LogonUserIdentity != null &&
                typeof(System.Security.Principal.WindowsIdentity).IsInstanceOfType(System.Web.HttpContext.Current.Request.LogonUserIdentity)
                )
            {
                model.LdapAccount = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name;
            }

            var result = AuthenticationFactory.Login(model);

            if (result)
            {
                return(Ok(new { success = true, suggestedUrl = new MembershipCashierW.Code.UrlRouting.UrlRouter().GetEntryPage() }));
            }

            return(Unauthorized());
        }
        catch (AuthenticationFactory.UnauthorizedException ex)
        {
            if (!ex.GenerateCaptcha)
            {
                return(Unauthorized());
            }

            return(Unauthorized(new AuthenticationHeaderValue("captcha_img", _AuthenticationFactory.GenerateCaptcha())));
        }
        catch (Exception ex)
        {
            this.HandleError(ex);
            return(Unauthorized());
        }
    }