public IActionResult LoginCheck(UserDto userDto) { if (userDto == null || string.IsNullOrEmpty(userDto.LoginId)) { userDto.Password = ""; return(View("Login")); } try { var userMaster = _mapper.Map <UserMaster>(userDto); //パースワードチェック var user = _userService.Authenticate(userDto.LoginId, userDto.Password); if (user == null) { ViewBag.Message = String.Format(ApiConstant.ERR01); userMaster.Password = ""; return(View("Login", userMaster)); } //役割チェック ROLE_ADMIN または ROLE_WORK if (!string.Equals(user.Role, ApiConstant.ROLE_ADMIN)) { ViewBag.Message = String.Format(ApiConstant.ERR08); userMaster.Password = ""; return(View("Login", userMaster)); } // 担当者状態のセッションキーチェック var userStatus = _userStatusService.GetById(user.LoginId); if (string.Equals(userDto.SessionKey, "undefined") || userStatus == null || !string.Equals(userDto.SessionKey, userStatus.SessionKey)) { string sessionKey = HttpContext.Session.Id; HttpContext.Session.SetString("SessionKey", sessionKey); userStatus = _userStatusService.UpdateOrCreate(user.LoginId, sessionKey); } ViewBag.LoginName = user.LoginName; return(View("Home", userStatus)); } catch (Exception) { ViewBag.Message = String.Format(ApiConstant.ERR90); return(View("Login")); } }