public async Task <IActionResult> OnPostAsync(string returnUrl = null) { DeBank.Library.DAL.MockingData _dataService = DeBank.Library.DAL.MockingData.GetMockDataService(); returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure : false); if (result.Succeeded) { var item = _dataService.ReturnAllUsers().Where(a => a.Name == Input.Email && a.Password == Input.Password).FirstOrDefault(); if (item == null) { var generateduser = new DeBank.Library.Models.User() { Id = Guid.NewGuid().ToString(), DateOfCreation = DateTime.Now, Email = Input.Email, Name = Input.Email, Password = Input.Password }; StaticResources.CurrentUser.currentuser = generateduser; } else { StaticResources.CurrentUser.currentuser = item; } TempData["CURRENTUSER"] = item; _logger.LogInformation("User logged in."); return(RedirectToAction("SubAccountsOverview", "RegularUserOverview")); } if (result.RequiresTwoFactor) { return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe })); } if (result.IsLockedOut) { _logger.LogWarning("User account locked out."); return(RedirectToPage("./Lockout")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(Page()); } } // If we got this far, something failed, redisplay form return(Page()); }
public IActionResult RemoveBankAccount(BankAccount account) { try { var item = _dataService.ReturnAllUsers().Where(a => a.Accounts.Contains(account)).FirstOrDefault(); if (item.Accounts.Count <= 1) { GeneralMethods.ShowMinimumOneBankAccountNeededMessage(); return(View()); } else { item.Accounts.Remove(account); _dataService.UpdateUser(item); } return(RedirectToAction("SubAccountsOverview", "RegularUserOverview")); } #pragma warning disable CS0168 // Variable is declared but never used catch (NullReferenceException ex) #pragma warning restore CS0168 // Variable is declared but never used { ViewBag.Message = "Wrong value input, please try a valid value"; return(View()); } #pragma warning disable CS0168 // Variable is declared but never used catch (ArgumentNullException ex) #pragma warning restore CS0168 // Variable is declared but never used { ViewBag.Message = "Wrong value input, please try a valid value"; return(View()); } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception ex) #pragma warning restore CS0168 // Variable is declared but never used { ViewBag.Message = "Something went wrong, try again"; return(View()); } }
public void AssignStaticresources() { DeBank.Library.DAL.MockingData _dataService = DeBank.Library.DAL.MockingData.GetMockDataService(); StaticResources.CurrentUser.currentuser = _dataService.ReturnAllUsers().Where(a => a.Name == Input.Email && a.Password == Input.Password).FirstOrDefault(); }