Пример #1
0
        public async Task <IActionResult> Login([FromBody] TokenBindingModel model)
        {
            var claims = _deSerializeJwtToken.GetClaims(model.AccessToken);

            if (claims.GetUserId() <= 0)
            {
                return(BadRequest(new BadRequestResponseModel(ErrorMessages.AuthenticatinError, "Can not authenticate user.")));
            }

            var authProperties = new AuthenticationProperties
            {
                IsPersistent = claims.GetIsPersistent(),
                ExpiresUtc   = model.ExpiresAtUtc
            };

            var claimsIdentity = new ClaimsIdentity(
                claims,
                CookieAuthenticationDefaults.AuthenticationScheme);

            await HttpContext.SignInAsync(
                CookieAuthenticationDefaults.AuthenticationScheme,
                new ClaimsPrincipal(claimsIdentity),
                authProperties);

            return(Ok());
        }
        public async Task <IHttpActionResult> GetUserToken(TokenBindingModel model)
        {
            var GetToken = this.GetToken(model.Email, model.Password);

            return(Ok(GetToken));
        }