public long ReSetPassword(TblUser entity) { var user = da.TblUser.Find(entity.ID); if (user != null) { //kan.HanViet = entity.HanViet; try { // set data user.Password = SafePassword.GetSaltedPassword(Constant.DEFAULT_PASSWORD); user.Email_Confirm = Constant.ConfirmEmail.RESET_PASSWORD; user.Status = Constant.Status.NONE; user.ModifiedDate = DateTime.Now; da.SaveChanges(); } catch (Exception ex) { throw ex; } } else { return(0); } return(entity.ID); }
private void DoSubmit() { User loginUser; try { loginUser = RepositoryFactory.instance.UserRepository.FindOne(Id, SafePassword.GetStretchedPassword(Id, Password)); } catch { loginUser = new User(); } if (loginUser is null) { MessageDialogRequest.Raise( new MessageNotification() { Title = "ERROR", IconKind = "AlertDecagram", Message = "Login Failed!!!!!", ButtonContent = "OK" }); } else { RegionService.MainNavigate(nameof(MainPage), nameof(SecondPage)); } }
public ActionResult SetNewPassword(SetNewPasswordViewModel model) { if (ModelState.IsValid) { if (model.NewPassword != model.NewPasswordConfirm) { ModelState.AddModelError("", string.Format(Resources.Messages.E048)); } else { using (TransactionScope transaction = new TransactionScope()) { if (_service.UpdatePassword(model.UserId, SafePassword.GetSaltedPassword(model.NewPassword), model.PasswordLockTarget, model.CompanyCode) > 0) { if (_service.DeletePasswordResetInfo(model.Email, model.CompanyCode) > 0) { transaction.Complete(); FormsAuthentication.SignOut(); Session.Clear(); ViewBag.MessageSuccess = String.Format(Resources.Messages.I017); } } } } } return(View("SetNewPassword", model)); }
public User(string m_LoginName, string m_Password, string m_Type, SafePassword m_SafePassword) { this.m_LoginName = m_LoginName; this.m_Password = m_Password; this.m_SafePassword = m_SafePassword; this.m_Type = m_Type; m_BookCount = 0; m_Error = false; }
private void DoAddUser() { User insertItem = new User { Id = this.UserId, Password = SafePassword.GetStretchedPassword(UserId, UserPassword) }; RepositoryFactory.instance.UserRepository.Insert(insertItem); FinishInteraction(); }
public ActionResult PasswordReissue(PasswordReissueViewModel model) { bool isError = true; if (ModelState.IsValid) { var user = _service.CheckEmail(model.Email); if (user.Count > 0) { if (user.Count == 1) { using (TransactionScope transaction = new TransactionScope()) { DateTime now = Utility.GetCurrentDateTime(); string param_value = SafePassword.GetSha256(model.Email + user[0].company_code + now.ToString("yyyy/MM/dd HH:mm:ss")); int count = _service.UpdatePasswordResetManagement(model.Email, param_value, now, user[0].company_code); //Sent mail new password if (count > 0) { var objSentMail = new SentMailAuto(); if (objSentMail.SentMail(model.Email, param_value, user[0].user_account) > 0) { transaction.Complete(); TempData["PasswordReissueSucess"] = Resources.Messages.I001; isError = false; } else { ModelState.AddModelError("", Resources.Messages.E012); } } } } else { TempData[TEMPDATA_EMAIL] = new TmpValues() { Email = model.Email }; return(RedirectToAction("InputCompanyCode", "PMS01001")); } } else { ModelState.AddModelError("", String.Format(Resources.Messages.E007, "メールアドレス", "メールアドレス")); } } if (!isError) { return(RedirectToAction("PasswordReissue", "PMS01001")); } return(View(model)); }
public ActionResult Login(string userName) { try { LoginModel model = new LoginModel(); TryUpdateModel(model); if (ModelState.IsValid) { UserDa da = new UserDa(); model.USER_PASSWORD = SafePassword.GetSaltedPassword(model.USER_PASSWORD); var exist = da.Login(model.USER_EMAIL, model.USER_PASSWORD); if (exist) { CmnEntityModel session = new CmnEntityModel(); var user = da.getUserByEmail(model.USER_EMAIL); session.UserName = user.UserName; session.Email = user.Email; session.ID = user.ID; session.IsAdmin = user.IsAdmin; session.Phone = user.Phone; session.Status = user.Status; session.USER_DISTRICT = user.Receive_District.HasValue ? user.Receive_District.Value : 0; session.USER_ADDRESS = user.Receive_Address; Session.Add("CmnEntityModel", session); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Email hoặc mật khẩu không đúng!"); } } return(View()); } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; System.Web.HttpContext.Current.Session["ERROR"] = ex; return(new EmptyResult()); } }
public long InsertUser(UserAccountModel model) { long res = 0; // Declare new DataAccess object UserAccountDa dataAccess = new UserAccountDa(); using (var transaction = new TransactionScope()) { TblUserAccount entity = new TblUserAccount(); entity.USER_EMAIL = model.USER_EMAIL; entity.EMAIL_CONFIRMED = EmailConfirmed.None; entity.USER_NAME = model.USER_NAME; entity.SHOP_NAME = model.SHOP_NAME; entity.USER_PASSWORD = SafePassword.GetSaltedPassword(model.USER_PASSWORD); entity.PASSWORD_LAST_UPDATE_DATE = Utility.GetCurrentDateTime(); entity.USER_AUTHORITY = User_Authority.Set_Person; entity.AREA = model.AREA; entity.USER_CITY = model.USER_CITY; entity.USER_DISTRICT = model.USER_DISTRICT; entity.USER_TOWN = model.USER_TOWN; entity.USER_ADDRESS = model.USER_ADDRESS; entity.USER_PHONE = model.USER_PHONE; entity.USER_FAMILY = 0; entity.LOGIN_LOCK_FLG = LockFlag.NON_LOCK; entity.GENDER = true; entity.DEL_FLG = DeleteFlag.NON_DELETE; entity.STATUS = StatusFlag.NON_DISPLAY; // user chua duoc active entity.INS_DATE = Utility.GetCurrentDateTime(); entity.UPD_DATE = Utility.GetCurrentDateTime(); res = dataAccess.InsertUser(entity); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
public UserAccountModel getInfoUser(UserAccountModel model) { string sql = @" SELECT A.*, B.CITY_NAME, C.DISTRICT_NAME, D.TOWN_NAME FROM TblUserAccount A LEFT JOIN MstCity B ON A.USER_CITY = B.CITY_CD LEFT JOIN MstDistrict C ON A.USER_CITY = C.CITY_CD AND A.USER_DISTRICT = C.DISTRICT_CD LEFT JOIN MstTown D ON A.USER_CITY = D.CITY_CD AND A.USER_DISTRICT = D.DISTRICT_CD AND A.USER_TOWN = D.TOWN_CD WHERE A.USER_EMAIL = @USER_EMAIL AND A.USER_PASSWORD = @USER_PASSWORD AND A.DEL_FLG = @DEL_FLG"; return(base.SingleOrDefault <UserAccountModel>(sql.ToString(), new { USER_EMAIL = model.USER_EMAIL, USER_PASSWORD = SafePassword.GetSaltedPassword(model.USER_PASSWORD), DEL_FLG = DeleteFlag.NON_DELETE })); }
public long ReSetPassword(long userId) { StringBuilder sqlinsert = new StringBuilder(); TblUserAccount entity = new TblUserAccount(); string password = "******"; password = SafePassword.GetSaltedPassword(password); sqlinsert.Append(@" UPDATE [TblUserAccount] SET [EMAIL_CONFIRMED] = @EMAIL_CONFIRMED ,[USER_PASSWORD] = @USER_PASSWORD ,[UPD_DATE] = @UPD_DATE WHERE [USER_ID] = @USER_ID"); return(base.Execute(sqlinsert.ToString(), new { USER_ID = userId, EMAIL_CONFIRMED = EmailConfirmed.RePassword, USER_PASSWORD = password, UPD_DATE = Utility.GetCurrentDateTime() })); }
public long UpdatePassword(UserModel model) { long res = 0; // Declare new DataAccess object UserDa dataAccess = new UserDa(); using (var transaction = new TransactionScope()) { TblUser entity = new TblUser(); entity.ID = model.ID; entity.Password = SafePassword.GetSaltedPassword(model.NEW_PASSWORD); res = dataAccess.UpdatePassword(entity); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
public long InsertUser(UserModel model) { long res = 0; // Declare new DataAccess object UserDa dataAccess = new UserDa(); TblUser User = new TblUser(); User.Email = model.Email; User.UserName = model.UserName; User.Password = SafePassword.GetSaltedPassword(model.Password); User.Phone = model.Phone; User.IsAdmin = false; // Chưa xác nhận email User.Email_Confirm = Constant.ConfirmEmail.CONFIRMED; User.Status = Constant.Status.ACTIVE; User.del_flg = Constant.DeleteFlag.NON_DELETE; User.CreatedDate = DateTime.Now; res = dataAccess.InsertUser(User); return(res); }
public ActionResult PersonalSetting(PMS01002PersonalSettingViewModel model) { try { int userId = GetLoginUser().UserId; if (userId > 0) { model.USER_INFO.user_sys_id = userId; } if (ModelState.IsValid) { if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { if (model.USER_INFO.password.Length < 6) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード")); return(new EmptyResult()); } if (!Regex.IsMatch(model.USER_INFO.password, Constant.REG_PASSWORD)) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード")); return(new EmptyResult()); } } if (model.confirmPassword != Constant.DISPLAY_PASSWORD) { if (model.confirmPassword.Length < 6) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード(確認用)")); return(new EmptyResult()); } if (!Regex.IsMatch(model.confirmPassword, Constant.REG_PASSWORD)) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード(確認用)")); return(new EmptyResult()); } } if (model.USER_INFO.password != model.confirmPassword) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E048)); return(new EmptyResult()); } var sessionLogin = Session[Constant.SESSION_LOGIN_USER] as LoginUser; if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { if (SafePassword.GetSaltedPassword(model.USER_INFO.password) == sessionLogin.Password) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", string.Format(Resources.Messages.E053)); return(new EmptyResult()); } } HttpPostedFileBase file = Request.Files["file"]; HttpPostedFileBase fileDrag = Request.Files["fileDrag"]; if (model.TypeUpload == "file" && file != null && file.FileName.Length > 0) { if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg")); return(new EmptyResult()); } if (file.ContentLength > Constant.MaxContentLength) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内")); return(new EmptyResult()); } model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]); } else if (model.TypeUpload == "fileDrag" && fileDrag != null && fileDrag.FileName.Length > 0) { file = fileDrag; if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg")); return(new EmptyResult()); } if (file.ContentLength > Constant.MaxContentLength) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内")); return(new EmptyResult()); } model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]); } else { if (model.Clear == "1") { model.USER_INFO.image_file_path = string.Empty; } } model.USER_INFO.upd_date = Utility.GetCurrentDateTime(); model.USER_INFO.upd_id = userId; model.USER_INFO.company_code = GetLoginUser().CompanyCode; model.USER_INFO.password_lock_flg = Constant.PasswordLockFlag.NON_LOCK; model.USER_INFO.language_id = (model.USER_INFO.language_id != null) ? model.USER_INFO.language_id : 0; if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { model.USER_INFO.password = SafePassword.GetSaltedPassword(model.USER_INFO.password); } if (!string.IsNullOrEmpty(model.USER_INFO.mail_address_1) || !string.IsNullOrEmpty(model.USER_INFO.mail_address_2)) { if (model.USER_INFO.mail_address_1.Trim() == model.USER_INFO.mail_address_2.Trim()) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス")); return(new EmptyResult()); } if (_service.CheckUserEmail(model.USER_INFO.mail_address_1, model.USER_INFO.mail_address_2, model.USER_INFO.user_sys_id, GetLoginUser().CompanyCode) > 0) { model = MakePersonalSettingViewModel(userId); ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス")); return(new EmptyResult()); } } if (_service.PersonalSettingUserData(model.USER_INFO) > 0) { if (file != null && file.FileName.Length > 0) { UploadFile.CreateFolder(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId.ToString()); model.USER_INFO.user_sys_id = userId; model.USER_INFO.del_flg = Constant.DeleteFlag.NON_DELETE; model.USER_INFO.image_file_path = ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.')); model.USER_INFO.row_version = this._service.GetUserInfo(GetLoginUser().CompanyCode, userId).row_version; if (_service.PersonalSettingUserData(model.USER_INFO) > 0) { // Move image UploadFile.MoveFile(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH] + "/" + file.FileName, ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + GetLoginUser().CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.'))); } } if (sessionLogin.Password != model.USER_INFO.password && model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { sessionLogin.Password = model.USER_INFO.password; sessionLogin.Is_expired_password = false; } if (sessionLogin.DisplayName != model.USER_INFO.display_name) { sessionLogin.DisplayName = model.USER_INFO.display_name; } if (sessionLogin.ImageFilePath != model.USER_INFO.image_file_path) { sessionLogin.ImageFilePath = model.USER_INFO.image_file_path; } if (sessionLogin.ActualWorkInputMode != model.USER_INFO.actual_work_input_mode) { sessionLogin.ActualWorkInputMode = model.USER_INFO.actual_work_input_mode; } SetLoginUser(sessionLogin); string action = model.USER_INFO.user_sys_id > 0 ? "更新" : "登録"; string message = string.Format(Resources.Messages.I007, "ユーザー情報", action); model = MakePersonalSettingViewModel(userId); JsonResult result = Json( new { statusCode = 201, message = message, id = model.USER_INFO.user_sys_id, row_version = Convert.ToBase64String(model.USER_INFO.row_version), imageFilePath = model.USER_INFO.image_file_path, userNameSesssion = sessionLogin.DisplayName }, JsonRequestBehavior.AllowGet); return(result); } else { if (model.USER_INFO.user_sys_id > 0) // Duplicate action update { ViewBag.Duplicate = "/PMS01002/PersonalSetting"; string companyCode = GetLoginUser().CompanyCode; model.GROUP_LIST = this.commonService.GetUserGroupSelectList(companyCode); model.POSITION_LIST = this.GetPositionList(companyCode); model.LANGUAGE_LIST = this.GetLanguageList(); return(new EmptyResult()); } else { ModelState.AddModelError("", Resources.Messages.E001); return(new EmptyResult()); } } } ModelState.AddModelError("", Resources.Messages.E001); return(new EmptyResult()); } catch { JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "ユーザー情報") }, JsonRequestBehavior.AllowGet); return(result); } }
public ActionResult EditUser(PMS01002EditViewModel model) { try { if (ModelState.IsValid) { var tmp_user_sys_id = model.USER_INFO.user_sys_id; //Check min lengthe of password if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { if (model.USER_INFO.password.Length < 6) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", string.Format(Resources.Messages.E023, "パスワード")); return(new EmptyResult()); } if (!Regex.IsMatch(model.USER_INFO.password, Constant.REG_PASSWORD)) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", string.Format(Resources.Messages.E003, "パスワード")); return(new EmptyResult()); } } HttpPostedFileBase file = Request.Files["file"]; HttpPostedFileBase fileDrag = Request.Files["fileDrag"]; if (model.TypeUpload == "file" && file != null && file.FileName.Length > 0) { if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg")); return(new EmptyResult()); } if (file.ContentLength > Constant.MaxContentLength) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内")); return(new EmptyResult()); } model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]); } else if (model.TypeUpload == "fileDrag" && fileDrag != null && fileDrag.FileName.Length > 0) { file = fileDrag; if (!Constant.AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.')))) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E010, "jpg,png.jpeg")); return(new EmptyResult()); } if (file.ContentLength > Constant.MaxContentLength) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E021, "500KB以内")); return(new EmptyResult()); } model.USER_INFO.image_file_path = UploadFile.UploadFiles(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH], file, ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH]); } else { if (model.Clear == "1") { model.USER_INFO.image_file_path = string.Empty; } } var loginUser = this.GetLoginUser(); model.USER_INFO.upd_date = Utility.GetCurrentDateTime(); model.USER_INFO.upd_id = loginUser.UserId; model.USER_INFO.company_code = loginUser.CompanyCode; if (model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { model.USER_INFO.password = SafePassword.GetSaltedPassword(model.USER_INFO.password); var user = _service.CheckPassword(model.USER_INFO.user_account, loginUser.CompanyCode, model.USER_INFO.user_sys_id); if (user != null && model.USER_INFO.password == user.password) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", string.Format(Resources.Messages.E053)); return(new EmptyResult()); } } if (!string.IsNullOrEmpty(model.USER_INFO.mail_address_1) || !string.IsNullOrEmpty(model.USER_INFO.mail_address_2)) { if (model.USER_INFO.mail_address_1.Trim() == model.USER_INFO.mail_address_2.Trim()) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス")); return(new EmptyResult()); } if (_service.CheckUserEmail(model.USER_INFO.mail_address_1, model.USER_INFO.mail_address_2, model.USER_INFO.user_sys_id, loginUser.CompanyCode) > 0) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E008, "メールアドレス", "メールアドレス")); return(new EmptyResult()); } } if (_service.CheckUserAccount(model.USER_INFO.user_account, loginUser.CompanyCode, model.USER_INFO.user_sys_id) > 0) { model = MakeEditViewModel(model.USER_INFO.user_sys_id); ModelState.AddModelError("", String.Format(Resources.Messages.E008, "ユーザーアカウント", "ユーザーアカウント")); return(new EmptyResult()); } if ((model.USER_INFO.user_sys_id == 0 || (model.OLD_DEL_FLAG && Constant.DeleteFlag.NON_DELETE.Equals(model.USER_INFO.del_flg))) && !this.commonService.CheckValidUpdateData(loginUser.CompanyCode, Constant.LicenseDataType.USER)) { JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E067, "ユーザー") }, JsonRequestBehavior.AllowGet); return(result); } int userId = _service.EditUserData(model.USER_INFO); if (userId > 0) { if (file != null && file.FileName.Length > 0) { UploadFile.CreateFolder(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId.ToString()); model.USER_INFO.user_sys_id = userId; if (model.USER_INFO.del_flg == null) { model.USER_INFO.del_flg = Constant.DeleteFlag.NON_DELETE; } model.USER_INFO.image_file_path = ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.')); model.USER_INFO.row_version = this._service.GetUserInfo(loginUser.CompanyCode, userId).row_version; if (_service.EditUserData(model.USER_INFO) > 0) { // Move image UploadFile.MoveFile(ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.TEMP_USER_PATH] + "/" + file.FileName, ConfigurationManager.AppSettings[ConfigurationKeys.SAVE_BASE_FILE_PATH] + ConfigurationManager.AppSettings[ConfigurationKeys.USER_PATH] + "/" + loginUser.CompanyCode + "/" + userId + "/" + ConfigurationManager.AppSettings[ConfigurationKeys.PROFILE_IMAGE] + file.FileName.Substring(file.FileName.LastIndexOf('.'))); } } model.USER_INFO.user_sys_id = userId; //update new user_id to model //update unit price history if (_service.UpdateUnitPriceHistory(model.USER_INFO, model.USER_INFO.upd_id) > 0) { var sessionLogin = Session[Constant.SESSION_LOGIN_USER] as LoginUser; if (sessionLogin.UserId == userId && sessionLogin.DisplayName != model.USER_INFO.display_name) { sessionLogin.DisplayName = model.USER_INFO.display_name; } if (sessionLogin.UserId == userId && sessionLogin.ImageFilePath != model.USER_INFO.image_file_path) { sessionLogin.ImageFilePath = model.USER_INFO.image_file_path; } if (sessionLogin.UserId == userId && sessionLogin.Password != model.USER_INFO.password && model.USER_INFO.password != Constant.DISPLAY_PASSWORD) { sessionLogin.Password = model.USER_INFO.password; sessionLogin.Is_expired_password = false; } if (sessionLogin.UserId == userId && sessionLogin.ActualWorkInputMode != model.USER_INFO.actual_work_input_mode) { sessionLogin.ActualWorkInputMode = model.USER_INFO.actual_work_input_mode; } SetLoginUser(sessionLogin); string action = Convert.ToInt32(tmp_user_sys_id) > 0 ? "更新" : "登録"; string message = string.Format(Resources.Messages.I007, "ユーザー情報", action); var data = this._service.GetUserInfo(loginUser.CompanyCode, userId); JsonResult result = Json( new { statusCode = 201, message = message, id = userId, row_version = Convert.ToBase64String(data.row_version), insDate = (data.ins_date != null) ? data.ins_date.ToString("yyyy/MM/dd HH:mm") : "", updDate = (data.upd_date != null) ? data.upd_date.ToString("yyyy/MM/dd HH:mm") : "", insUser = data.user_regist, updUser = data.user_update, deleted = data.del_flg.Equals(Constant.DeleteFlag.DELETE) ? true : false, imageFilePath = data.image_file_path, userIDSesssion = loginUser.UserId, userNameSesssion = sessionLogin.DisplayName }, JsonRequestBehavior.AllowGet); return(result); } else { ModelState.AddModelError("", Resources.Messages.E001); JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "ユーザー情報") }, JsonRequestBehavior.AllowGet); return(result); } } else { ModelState.AddModelError("", Resources.Messages.E001); JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "ユーザー情報") }, JsonRequestBehavior.AllowGet); return(result); } } return(new EmptyResult()); } catch (Exception) { JsonResult result = Json( new { statusCode = 500, message = string.Format(Resources.Messages.E045, "ユーザー情報") }, JsonRequestBehavior.AllowGet); return(result); } }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { string reg = @"^[a-zA-Z0-9\!\""\#\$\%\&\'\(\)\=\~\|\-\^\@\[\;\:\]\,\.\/\`\{\+\*\}\>\?]*$"; //Check min length user acount and password if (model.UserAccount.Length > 32 || model.Password.Length < 6 || model.Password.Length > 32 || !Regex.IsMatch(model.UserAccount, reg) || !Regex.IsMatch(model.Password, reg)) { ModelState.AddModelError("", string.Format(Messages.E029)); return(View(model)); } // Check if account has been locked if (this._service.IsLockedUser(model.CompanyCode, model.UserAccount)) { ModelState.AddModelError("", Messages.E014); return(View(model)); } // Check UserAccount and Password LoginUser user = _service.Login(model.CompanyCode, model.UserAccount, SafePassword.GetSaltedPassword(model.Password)); if (user != null) { if (this._service.CheckLicense(model.CompanyCode) == 0) { ModelState.AddModelError("", string.Format(Messages.E066)); return(View(model)); } FormsAuthentication.SetAuthCookie(user.UserAccount, false); SetLoginUser(user); // Check if password has been expired int effective_month = this._service.GetPasswordEffectiveMonth(GetLoginUser().CompanyCode); if (effective_month == 0) { user.Is_expired_password = false; } if (user.Is_expired_password) { ViewBag.PASSWORD_EXPIRED = string.Format(Messages.I005, effective_month); return(View(model)); } return(RedirectToAction("Index", "PMS08001")); } else { // Check if the input UserAccount is existed int?userId = this._service.IsExistedUserId(model.CompanyCode, model.UserAccount); if (userId != null) { // Get list of invalid user from session var _listInvalidUser = Session[Constant.SESSION_INVALID_LOGIN_USER] as List <UserLoginInvalid>; bool isnew = true; if (_listInvalidUser != null) { // get the limit of input password times int limtInput = this._service.GetLimitInputPassword(model.CompanyCode); foreach (var invalidUser in _listInvalidUser) { if (invalidUser.CompanyCode == model.CompanyCode && invalidUser.UserId == userId) { isnew = false; invalidUser.InvalidCount++; if (invalidUser.InvalidCount >= limtInput) { // reach the limit input times, lock password this._service.LockUser(model.CompanyCode, (int)userId); ModelState.AddModelError("", Messages.E013); return(View(model)); } } } } else { _listInvalidUser = new List <UserLoginInvalid>(); } ModelState.AddModelError("", string.Format(Messages.E007, "入力された内容", "アカウント")); if (isnew) { _listInvalidUser.Add(new UserLoginInvalid(model.CompanyCode, (int)userId)); } // save list of invalid user to session Session[Constant.SESSION_INVALID_LOGIN_USER] = _listInvalidUser; } else { ModelState.AddModelError("", String.Format(Resources.Messages.E007, "入力された内容", "アカウント")); } } } return(View(model)); }