public int Verify(UserVerifyModel model) { var user = _context.Users.SingleOrDefault(x => x.Username == model.Username); if (user == null) { throw new AppException("Username not found"); } // check if password is correct try { if (!VerifyPasswordHash(model.Password, user.PasswordHash, user.PasswordSalt)) { throw new AppException("Invalid password"); } } catch (ArgumentException) { throw new AppException("Issue parsing password"); } MasterCredHelper masterCredHelper = new MasterCredHelper(); if (model.MasterCred != null) { if (!masterCredHelper.VerifyMasterCred(user, model.MasterCred)) { throw new AppException("Invalid master credential"); } } return(user.Id); }
public async Task <IActionResult> OnGet() { userVerifyModel = new UserVerifyModel(); byte[] bytes; HttpContext.Session.TryGetValue("_username", out bytes); if (bytes != null) { userVerifyModel.UserName = Encoding.ASCII.GetString(bytes); } else { HttpContext.Session.Set("_msg", Encoding.ASCII.GetBytes("You have to start with Password Reset Service Landing Page.")); return(RedirectToPage("./Result")); } ApiResult result = new ApiResult(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(Constants.API_BASE_URL); UserResetPwdInfo info = new UserResetPwdInfo(); info.UserName = userVerifyModel.UserName; using (var response = await client.PostAsJsonAsync <UserResetPwdInfo>("GetUserEmail", info)) { string apiResponse = await response.Content.ReadAsStringAsync(); userVerifyModel.EmailAddr = apiResponse; } } return(Page()); }
public IActionResult Verify([FromBody] UserVerifyModel model) { try { var userId = _userService.Verify(model); return(Ok(new { Id = userId })); } catch (AppException e) { return(BadRequest(new { Error = e.Message })); } }