public async Task <ActionResult <LoginInfo> > GetLoginInfo(string login_challenge) { var loginInfo = await _hydra.GetLoginInfo(login_challenge); if (loginInfo.Skip) { var signInLog = new SignInLog { UserName = loginInfo.Subject, IpAddress = Request.Headers["X-Real-IP"], UserAgent = Request.Headers["User-Agent"], AcceptedLoginAt = DateTimeOffset.Now, LoginChallenge = login_challenge }; _db.Add(signInLog); await _db.SaveChangesAsync(); var appuser = await _userManager.FindByNameAsync(loginInfo.Subject); if (appuser == null) { var response = await _hydra.RejectLogin(new RejectRequest { Error = "user not found", ErrorDescription = $"subject {loginInfo.Subject} not found" }, login_challenge); return(BadRequest(response)); } return(Ok(loginInfo)); } return(Ok(loginInfo)); }
public async Task <ActionResult <LoginInfo> > GetLoginInfo(string login_challenge) { var loginInfo = await _hydra.GetLoginInfo(login_challenge); if (loginInfo.Skip) { var user = await _userManager.FindByIdAsync(loginInfo.Subject); if (user == null) { return(BadRequest(IDPErrors.UserNotFound)); } loginInfo.Username = user.UserName; return(Ok(loginInfo)); } return(Ok(loginInfo)); }