public async Task <IActionResult> LoginRequest([FromBody] CmsRequest loginRequest) { var cms = _pkiManager.GetCMS(loginRequest.Cms); var randomArrayFromSession = HttpContext.Session.Get("RandomString"); byte[] randomArrayFromCms; try { randomArrayFromCms = _pkiManager.VerifySignature(cms); } catch (Exception err) { return(BadRequest()); } if (!randomArrayFromSession.SequenceEqual(randomArrayFromCms)) { return(BadRequest()); } var user = _paymentService.GetUser(loginRequest.ObjectId); _paymentService.GenerateUserPayments(user.Id); var claims = new List <Claim> { new Claim("UserId", user.Id.ToString()), new Claim("UserName", user.UserName), new Claim("ObjectId", loginRequest.ObjectId) }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity)); return(Ok()); }
public IActionResult SavePayment([FromBody] Payment payment) { var userId = int.Parse(User.Claims.First(u => u.Type == "UserId").Value); var res = _pkiManager.GetCMS(payment.CMS); try { _pkiManager.VerifySignature(res); } catch (Exception err) { return(BadRequest()); } _paymentService.SavePayment(userId, payment); return(Ok()); }