public async Task <IActionResult> UpdateUser(int ID) { User_Infor user = new User_Infor(); user = await _adminService.GetUserInfo(Request, Response, ID); _cookieService.CreateCookie(Response, ID.ToString(), "id"); ViewBag.Infor = user; ViewBag.Cities = await _userService.GetCity(); return(View()); }
public async Task <IActionResult> ForgotPass(IFormCollection form) { var resetPassResult = await _userService.CheckEmail(form["Email"].ToString()); string a = resetPassResult.Content.ReadAsStringAsync().Result; Console.WriteLine(a); if (resetPassResult.IsSuccessStatusCode) { _cookieService.CreateCookie(Response, form["Email"].ToString(), "email"); ViewBag.Email = form["Email"].ToString(); return(View("ResetPasswordEmail")); } ViewBag.Message = a; return(View("ForgotPass")); }
public virtual Task <UserModel> Login(UserModel loginModel) { if (loginModel == null || string.IsNullOrEmpty(loginModel.UserName) || string.IsNullOrEmpty(loginModel.Password)) { return(Task.FromResult <UserModel>(null)); } var accessLogModel = new { Ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(), Username = loginModel.UserName, Password = loginModel.Password }; _accessLogger.Info($"{Newtonsoft.Json.JsonConvert.SerializeObject(accessLogModel)}"); bool passwordValid = ValidatePassword(loginModel); if (!passwordValid) { return(Task.FromResult <UserModel>(null)); } UserDBModel userModel = _userDAO.GetUser(loginModel.UserName); string cookie = _cookieService.CreateCookie(userModel, _httpContextAccessor.HttpContext); if (string.IsNullOrEmpty(cookie)) { return(Task.FromResult <UserModel>(null)); } loginModel.Password = null; loginModel.Cookie = cookie; loginModel.Status = "ok"; return(Task.FromResult(loginModel)); }
public void CreateUserCookie(HttpResponse Response, Cookie_Data data) { string a = JsonConvert.SerializeObject(data); _cookieService.CreateCookie(Response, a, "user"); }