示例#1
0
        protected async Task LogInMemberApi(string username, string password)
        {
            var response = await MemberApiProxy.Login(new LoginRequest
            {
                BrandId        = BrandId,
                Username       = username,
                IPAddress      = "::1",
                Password       = password,
                RequestHeaders = new Dictionary <string, string>()
            });

            Token = response.AccessToken;
        }
        public async Task <IHttpActionResult> Login(LoginRequest request)
        {
            request.BrandId = _brandId;
            var httpRequest = ((HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request;

            request.IPAddress      = GetIpRequest();
            request.RequestHeaders = httpRequest.Headers.ToDictionary();

            TokenResponse result;

            result = await _memberApiProxy.Login(request);

            var cookie = CreateAuthenticationCookie(result.AccessToken, request.Username, false);

            HttpContext.Current.Response.Cookies.Add(cookie);
            return(Ok(new { Success = true }));
        }