public bool UpdateUser(UserModel model) { if (model == null) { return(false); } try { var user = (from u in _db.SysUser where u.LoginID == model.LoginID select u).FirstOrDefault(); user.Name = model.Name; user.Email = model.Email; user.Mobile = model.Mobile; user.UpdateUid = model.ModifyUID; user.UpdateDate = DateTime.Now; user.Actived = model.Actived; if (model.PasswordNew != null) { user.Password = ED5Helper.Encrypt(model.PasswordNew); } ; _db.SaveChanges(); return(true); } catch (Exception ex) { LogHelper.Error("UserRepository:UpdateUser: "******" Inner Exception: " + ex.InnerException.Message); return(false); } }
public bool InsertUser(UserModel model) { if (model == null) { return(false); } try { var user = new SysUser() { //user.ID = Guid.NewGuid(); LoginID = model.LoginID, Password = ED5Helper.Encrypt(model.Password), Name = model.Name, Email = model.Email, Mobile = model.Mobile, CreateUid = model.ModifyUID, CreateDate = DateTime.Now, Deleted = false, Actived = true }; _db.SysUser.Add(user); _db.SaveChanges(); return(true); } catch (Exception ex) { LogHelper.Error("UserRepository:InsertUser: "******" Inner Exception: " + ex.InnerException.Message); return(false); } }
public bool InsertUser(UserModel model) { if (model == null) { return(false); } try { var user = new SysUser() { UserId = model.UserId, Password = ED5Helper.Encrypt(model.Password), UserName = model.UserName, Email = model.Email, Mobile = model.Mobile, //CreateUid = model.c, CreateDate = DateTime.Now, Deleted = false, Status = 1 }; _db.SysUser.Add(user); _db.SaveChanges(); return(true); } catch (Exception ex) { LogHelper.Error("UserRepository:InsertUser: "******" Inner Exception: " + ex.InnerException.Message); return(false); } }
public ActionResult UpdatePass(UserModel model) { var repository = new UserRepository(); var uStatus = repository.GetStatus(model.LoginID); var status = AppDictionary.UserStatus.FirstOrDefault(a => a.Value == uStatus).Key; model.PasswordOld = (status == "New" || status == "Reset" ? model.PasswordOld : ED5Helper.Encrypt(model.PasswordOld)); model.Password = repository.GetPassword(model.LoginID); if (model.Password != model.PasswordOld) { return(Json(new { result = "Error", mess = "The old password is entered incorrectly" })); } model.PasswordNew = (status == "New" || status == "Reset" ? model.PasswordNew : ED5Helper.Encrypt(model.PasswordNew)); if (model.PasswordNew == model.PasswordOld) { return(Json(new { result = "Error", mess = "The new password must have different with old password" })); } model.PasswordRepeat = (status == "New" || status == "Reset" ? model.PasswordRepeat : ED5Helper.Encrypt(model.PasswordRepeat)); if (model.PasswordNew != model.PasswordRepeat) { return(Json(new { result = "Error", mess = "The password entered does not match" })); } model.PasswordNew = ED5Helper.Encrypt(model.PasswordNew); var result = repository.ChangePassword(model.LoginID, model.PasswordNew); return(result ? Json(new { result = "OK" }) : Json(new { result = "Error", mess = "Update fail" })); }
public async Task <HttpResponseMessage> LoginByUserName(HttpRequestMessage request, UserInfo _userInfo) { if (!ModelState.IsValid) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } string result = ""; _userInfo.Password = ED5Helper.Encrypt(_userInfo.Password); ApplicationUser oUser = await SignInManager.UserManager.FindByNameAsync(_userInfo.UserName); //ApplicationUser oUser = await SignInManager.UserManager.FindByNameAsync(_userInfo.UserName, _userInfo.Password); eLoginResult objResult = new eLoginResult(); if (string.IsNullOrEmpty(oUser.Id) || oUser.IsDelete) { objResult.loginSuccess = false; objResult.errMessage = "User does not exist"; } else if (oUser.Password != _userInfo.Password) { objResult.loginSuccess = false; objResult.errMessage = "Wrong password"; } else { objResult.loginSuccess = true; objResult.userLogin = oUser; } return(request.CreateResponse(HttpStatusCode.OK, objResult)); }
public async Task <HttpResponseMessage> LoginByEmail(HttpRequestMessage request, UserInfo _userInfo) { if (!ModelState.IsValid) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } //ApplicationUser oUser = await SignInManager.UserManager.FindByNameAsync(userInfo.USERNAME); _userInfo.Password = ED5Helper.Encrypt(_userInfo.Password); ApplicationUser oUser = await SignInManager.UserManager.FindByEmailAsync(_userInfo.Email); string result = ""; if (string.IsNullOrEmpty(oUser.Id) || oUser.IsDelete) { result = "User does not exist"; } else if (oUser.Password != _userInfo.Password) { result = "Wrong password"; } else { result = "Login success"; } return(request.CreateResponse(HttpStatusCode.OK, result)); }
public JsonResult Insert(GuardModel model) { model.Password = ED5Helper.Encrypt(model.Password); var result = _rep.Insert(model, User.GetClaimValue(ClaimTypes.Sid)); return(Json(result, JsonRequestBehavior.AllowGet)); }
public bool InsertUser(UserModel model) { if (model == null) { return(false); } try { var user = new SysUser(); using (var db = new PORTALEntities()) { //user.ID = Guid.NewGuid(); user.LoginID = model.LoginID; user.Password = ED5Helper.Encrypt(model.Password); user.Name = model.Name; user.Email = model.Email; user.Mobile = model.Mobile; user.CreateUid = model.ModifyUID; user.CreateDate = DateTime.Now; user.Deleted = false; user.Actived = true; db.SysUsers.Add(user); db.SaveChanges(); return(true); } } catch (Exception ex) { LogHelper.Error("UserRepository:InsertUser: "******" Inner Exception: " + ex.InnerException.Message); return(false); } }
//cập nhật password cho nhân viên mới public int UpdatePassword() { var resetPass = new Guid(AppDictionary.UserStatus.FirstOrDefault(d => d.Key == "Reset").Value); var newUser = new Guid(AppDictionary.UserStatus.FirstOrDefault(d => d.Key == "New").Value); try { using (var db = new PORTALEntities()) { var list = db.HrEmpMasters.Where(e => e.uStatus == newUser).ToList(); list.ForEach(l => { l.uStatus = resetPass; l.Password = ED5Helper.Encrypt(l.Code); }); db.SaveChanges(); return(list.Count); } } catch (Exception ex) { LogHelper.Error("UserRepository: UpdatePassword: "******" Inner Exception: " + ex.InnerException.Message); return(-1); } }
private UserViewModel CheckLogin(LoginViewModel model) { var rep = new UserRepository(); model.Password = ED5Helper.Encrypt(model.Password); var res = new UserRepository(); return(res.Login(model)); }
public UserModel ValidateModel(LoginModel model) { var rep = new UserRepository(); model.Password = ED5Helper.Encrypt(model.Password); var res = new UserRepository(); return(res.Login(model)); }
public JsonResult Update(GuardModel model) { if (!string.IsNullOrEmpty(model.Password)) { model.Password = ED5Helper.Encrypt(model.Password); } var result = _rep.Update(model, User.GetClaimValue(ClaimTypes.Sid), true); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult createNewUser(string Username, string Password) { dynamic showMessageString = string.Empty; string sqlQuery = "sp_insert_new_user"; string pw = ED5Helper.Encrypt(Password); showMessageString = new { param1 = 200, param2 = "insert success", param3 = Username, param4 = pw }; OracleParameter[] sqlParams = new OracleParameter[3]; sqlParams[0] = new OracleParameter("PEMPID", Username); sqlParams[1] = new OracleParameter("PPASSWORD", OracleDbType.NVarchar2) { Value = pw }; sqlParams[2] = new OracleParameter("T_TABLE", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; DataTable dtResult = new DataTable(); try { dtResult = DBHelper.getDataTable_SP(sqlQuery, sqlParams); } catch (Exception ex) { showMessageString = new { param1 = 404, param2 = "proccess error", param3 = Username, param4 = pw }; } if (dtResult.Rows[0][0].ToString() != "OK") { showMessageString = new { param1 = 404, param2 = "proccess error", param3 = Username, param4 = pw }; } return(Json(showMessageString, JsonRequestBehavior.AllowGet)); }
public string Insert(string username, string password, int createdBy) { try { _db.InsertUser(username, ED5Helper.Encrypt(password), createdBy); return("Insert success!!"); }catch (Exception ex) { var Err = ex.InnerException; return("Fail nha!"); } }
public DataTable ChangePasswrod(string userI, string oldpass, string newpass) { oldpass = ED5Helper.Encrypt(oldpass); newpass = ED5Helper.Encrypt(newpass); OracleParameter[] param = new OracleParameter[4]; param[0] = new OracleParameter("pUserId", userI); param[1] = new OracleParameter("pOldpass", oldpass); param[2] = new OracleParameter("pNewpass", newpass); param[3] = new OracleParameter("T_TABLE", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; return(DBHelper.getDataTable_SP("PKOPM_USER.sp_User_ChangePass", param)); }
public UserModel ValidateModel(LoginModel model) { try { model.Password = ED5Helper.Encrypt(model.Password); UserRepository res = new UserRepository(); return(res.Login(model)); } catch (Exception ex) { LogHelper.Error("Controller: " + Request.RequestContext.RouteData.Values["Controller"].ToString() + " Action: " + Request.RequestContext.RouteData.Values["Action"].ToString() + " Method ValidateModel:" + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public ActionResult UpdatePassForSecurity(UserModel model) { var repository = new UserRepository(); model.PasswordNew = ED5Helper.Encrypt(model.PasswordNew); model.PasswordRepeat = ED5Helper.Encrypt(model.PasswordRepeat); if (model.PasswordNew != model.PasswordRepeat) { return(Json(new { result = "Error", mess = "The password entered does not match" })); } var result = repository.ChangePassword(model.LoginID, model.PasswordNew); return(result ? Json(new { result = "OK" }) : Json(new { result = "Error", mess = "Update fail" })); }
public ActionResult updateUserPassword(string UserId, string oldPassword, string newPassword, string newPasswordConfirm) { dynamic showMessageString = string.Empty; showMessageString = new { param1 = "OK", param2 = "Update success!!" }; if (string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword) || string.IsNullOrEmpty(newPasswordConfirm)) { showMessageString = new { param1 = "Error", param2 = "Please Check Data" }; return(Json(showMessageString, JsonRequestBehavior.AllowGet)); } if (newPassword != newPasswordConfirm) { showMessageString = new { param1 = "Error", param2 = "New password not match" }; return(Json(showMessageString, JsonRequestBehavior.AllowGet)); } string oldpass = ED5Helper.Encrypt(oldPassword); string newpass = ED5Helper.Encrypt(newPassword); UserAccess uAccess = new UserAccess(); DataTable dtResult = new DataTable(); dtResult = uAccess.ChangePasswrod(UserId, oldPassword, newPassword); if (dtResult.Rows[0][0].ToString() != "OK") { showMessageString = new { param1 = "Error", param2 = "Change password failed!!" }; return(Json(showMessageString, JsonRequestBehavior.AllowGet)); } return(Json(showMessageString, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage doLogin(HttpRequestMessage req, UserInfo _user) { return(CreateHttpResponse(req, () => { HttpResponseMessage res = null; if (!ModelState.IsValid) { res = req.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { _user.Password = ED5Helper.Encrypt(_user.Password); eLoginResult insertResult = aUserAccess.doLogin(_user.UserName, _user.Password); res = req.CreateResponse(HttpStatusCode.Created, insertResult); } return res; })); }
public HttpResponseMessage CreateNewUser(HttpRequestMessage request, UserInfo _userInfo) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { _userInfo.Password = ED5Helper.Encrypt(_userInfo.Password); bool updateResult = aUserAccess.createNewuser(_userInfo); response = request.CreateResponse(HttpStatusCode.Created, updateResult); } return response; })); }
internal DataTable Save(string workingTag, UserEntity user) { string spName = "PKOPM_USER.sp_User_Save"; OracleParameter[] para = new OracleParameter[16]; para[0] = new OracleParameter("pWorkingTag", workingTag); para[1] = new OracleParameter("pUserId", user.UserID); para[2] = new OracleParameter("pName", OracleDbType.NVarchar2) { Value = user.Name }; if (user.Password != "") { para[3] = new OracleParameter("pPassword", ED5Helper.Encrypt(user.Password)); } else { para[3] = new OracleParameter("pPassword", ""); } para[4] = new OracleParameter("pStaffId", user.StaffId); para[5] = new OracleParameter("pMobile", user.Mobile); para[6] = new OracleParameter("pEmail", user.Email); para[7] = new OracleParameter("pIPRestriction", user.IPRestriction); para[8] = new OracleParameter("pStartID", ToolHelper.IP2INT((user.StartIP == "") ? "0.0.0.0" : user.StartIP)); para[9] = new OracleParameter("pEndID", ToolHelper.IP2INT((user.EndIP == "") ? "0.0.0.0" : user.EndIP)); para[10] = new OracleParameter("pIsActive", user.IsActive); para[11] = new OracleParameter("pUpdateUID", user.UpdateUID); para[12] = new OracleParameter("pGroupId", user.GroupID); para[13] = new OracleParameter("pDEPTCODE", user.DEPTCODE); para[14] = new OracleParameter("pResetPass", user.ResetPass == true ? "Y" : "N"); para[15] = new OracleParameter("T_TABLE", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; return(DBHelper.getDataTable_SP(spName, para)); }
public UserModel ValidateModel(LoginModel model) { var rep = new UserRepository(); var uStatus = rep.GetStatus(model.LoginID); var status = AppDictionary.UserStatus.FirstOrDefault(a => a.Value == uStatus).Key; try { model.Password = (status == "New" || status == "Reset" ? model.Password : ED5Helper.Encrypt(model.Password)); var res = new UserRepository(); return(res.Login(model)); } catch (Exception ex) { LogHelper.Error("Controller: " + Request.RequestContext.RouteData.Values["Controller"].ToString() + " Action: " + Request.RequestContext.RouteData.Values["Action"].ToString() + " Method ValidateModel:" + ex.Message + " Inner Exception: " + ex.InnerException.Message); return(null); } }
public JsonResult UpdatePass(string guardId, string pass) { var result = _rep.UpdatePass(guardId, ED5Helper.Encrypt(pass), User.GetClaimValue(ClaimTypes.Sid)); return(Json(result, JsonRequestBehavior.AllowGet)); }
private bool LoginDB(string strUser, string strPwd) { string sqlQuery = "PKOPM_LOGIN.sp_Login"; strPwd = ED5Helper.Encrypt(strPwd); string ipAddress = getIP(); OracleParameter[] sqlParams = new OracleParameter[7]; sqlParams[0] = new OracleParameter("UserCd", strUser); sqlParams[1] = new OracleParameter("Pwd", strPwd); sqlParams[2] = new OracleParameter("Lang", "en"); sqlParams[3] = new OracleParameter("pIpAddress", ipAddress); sqlParams[4] = new OracleParameter("pSessionID", Session.SessionID); sqlParams[5] = new OracleParameter("T_TABLE1", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; sqlParams[6] = new OracleParameter("T_TABLE2", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; DataSet ds = DBHelper.getDataSet_SP(sqlQuery, sqlParams); if (ds == null || ds.Tables.Count == 0) { //MessageHelper.ShowMessage(this, "Error!"); return(false); } else { if (ds.Tables[0].Rows[0][0].ToString() == "Err") { //MessageHelper.ShowMessage(this, ds.Tables[0].Rows[0][1].ToString()); return(false); } else if (ds.Tables[0].Rows[0][0].ToString() == "OK" && ds.Tables.Count > 1) { int ipint = ToolHelper.IP2INT(ipAddress); if (ds.Tables[1].Rows[0]["IP_RESTRICTION"].ToString() != "1") { //_page.UserId = ds.Tables[1].Rows[0]["UserId"].ToString(); //_page.UserNm = ds.Tables[1].Rows[0]["UserName"].ToString(); //_page.UserCd = ds.Tables[1].Rows[0]["UserId"].ToString(); //_page.Email = ds.Tables[1].Rows[0]["user_email"].ToString(); //_page.GroupId = ds.Tables[1].Rows[0]["GROUP_ID"].ToString(); //_page.StaffId = ds.Tables[1].Rows[0]["STAFF_ID"].ToString(); //_page.CorporationCd = ds.Tables[1].Rows[0]["corporation"].ToString(); //_page.CorporationNm = ds.Tables[1].Rows[0]["corporationName"].ToString(); //_page.DepartmentCd = ds.Tables[1].Rows[0]["department"].ToString(); //_page.TeamCd = ds.Tables[1].Rows[0]["team"].ToString(); //_page.SectionCd = ds.Tables[1].Rows[0]["section"].ToString(); //_page.LangId = "en"; //_page.ListManagementDepartment = ds.Tables[1].Rows[0]["ListDepcode"].ToString(); //temp //_page.CorporationCd = "1001"; //Response.Redirect("~/Main.aspx"); Session["UserId"] = ds.Tables[1].Rows[0]["UserId"].ToString(); Session["UserName"] = ds.Tables[1].Rows[0]["UserName"].ToString(); Session["DeptsManage"] = ds.Tables[1].Rows[0]["ListDepcode"].ToString(); return(true); } else if (!(Convert.ToInt32(ds.Tables[1].Rows[0]["START_ID"]) <= ipint && ipint <= Convert.ToInt32(ds.Tables[1].Rows[0]["END_ID"]))) { //MessageHelper.ShowMessage(this, "Từ chối truy cập! User ko thể đăng nhập bên ngoài PK!"); //Response.Redirect("~/Login.aspx"); return(false); } else { //_page.UserId = ds.Tables[1].Rows[0]["UserId"].ToString(); //_page.UserNm = ds.Tables[1].Rows[0]["UserName"].ToString(); //_page.UserCd = ds.Tables[1].Rows[0]["UserId"].ToString(); //_page.Email = ds.Tables[1].Rows[0]["user_email"].ToString(); //_page.GroupId = ds.Tables[1].Rows[0]["GROUP_ID"].ToString(); //_page.StaffId = ds.Tables[1].Rows[0]["STAFF_ID"].ToString(); //_page.CorporationCd = ds.Tables[1].Rows[0]["corporation"].ToString(); //_page.CorporationNm = ds.Tables[1].Rows[0]["corporationName"].ToString(); //_page.DepartmentCd = ds.Tables[1].Rows[0]["department"].ToString(); //_page.TeamCd = ds.Tables[1].Rows[0]["team"].ToString(); //_page.SectionCd = ds.Tables[1].Rows[0]["section"].ToString(); //_page.LangId = "en"; //_page.ListManagementDepartment = ds.Tables[1].Rows[0]["ListDepcode"].ToString(); //temp //_page.CorporationCd = "1001"; //Response.Redirect("~/Main.aspx"); Session["UserId"] = ds.Tables[1].Rows[0]["UserId"].ToString(); Session["UserName"] = ds.Tables[1].Rows[0]["UserName"].ToString(); Session["DeptsManage"] = ds.Tables[1].Rows[0]["ListDepcode"].ToString(); return(true); } } else { //MessageHelper.ShowMessage(this, "Login Faile!"); return(false); } } }
private UserView CheckLogin(LoginView model) { model.Password = ED5Helper.Encrypt(model.Password); return(_re.Login(model)); }