public IActionResult Login(LoginInfoViewModel model) { string message = string.Empty; if (ModelState.IsValid) { string userId = "admin"; string password = "******"; if (model.UserId.Equals(userId) && model.Password.Equals(password)) { TempData["Message"] = "Login Successed"; } return(RedirectToAction("Index", "Membership")); } else { message = "Invalid input data"; } ModelState.AddModelError(string.Empty, message); return(View()); }
protected void AutoLoginForTest(HttpContextBase httpContext) { var AdminBD = BaseMvcApplication.WindsorContainer.Resolve <IAdminBD>(); var loginUser = AdminBD.GetLoginUser("admin", AppBaseController.DefaultPassword); var loginInfo = new LoginInfoViewModel(); loginInfo.LoginUser = loginUser; loginInfo.LoginCorp = loginUser.Dept.Corp; var tmp = loginInfo.LoginCorp.Name;//make proxy load the real entity var i = 0; foreach (var func in loginInfo.LoginCorp.Funcs) { loginInfo.AddCorpFuncCode(func.Code); } foreach (var func in loginUser.Dept.Funcs) { loginInfo.AddDeptFuncCode(func.Code); } foreach (var func in loginUser.Funcs) { loginInfo.AddUserFuncCode(func.Code); } httpContext.Session["LoginInfo"] = loginInfo; }
public async Task <IActionResult> LoginPageInfo( Guid?siteGuid, int slp = 1) { ISiteSettings selectedSite; // only server admin site can edit other sites settings if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite)) { selectedSite = await siteManager.Fetch(siteGuid.Value); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Login Page Content", selectedSite.SiteName); } else { selectedSite = siteManager.CurrentSite; ViewData["Title"] = "Login Page Content"; } LoginInfoViewModel model = new LoginInfoViewModel(); model.SiteGuid = selectedSite.SiteGuid; model.LoginInfoTop = selectedSite.LoginInfoTop; model.LoginInfoBottom = selectedSite.LoginInfoBottom; return(View(model)); }
public async Task <ActionResult> LoginPageInfo(LoginInfoViewModel model) { ISiteSettings selectedSite = null; if (model.SiteGuid == siteManager.CurrentSite.SiteGuid) { selectedSite = siteManager.CurrentSite; ViewData["Title"] = "Login Page Content"; } else if (siteManager.CurrentSite.IsServerAdminSite) { selectedSite = await siteManager.Fetch(model.SiteGuid); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Login Page Content", selectedSite.SiteName); } if (selectedSite == null) { this.AlertDanger("oops something went wrong.", true); return(RedirectToAction("Index")); } if (!ModelState.IsValid) { return(View(model)); } if (model.SiteGuid == Guid.Empty) { this.AlertDanger("oops something went wrong, site was not found.", true); return(RedirectToAction("Index")); } selectedSite.LoginInfoTop = model.LoginInfoTop; selectedSite.LoginInfoBottom = model.LoginInfoBottom; bool result = await siteManager.Save(selectedSite); if (result) { this.AlertSuccess(string.Format("Login Page Info for <b>{0}</b> was successfully updated.", selectedSite.SiteName), true); } if ((siteManager.CurrentSite.IsServerAdminSite) && (siteManager.CurrentSite.SiteGuid != selectedSite.SiteGuid) ) { return(RedirectToAction("LoginPageInfo", new { siteGuid = model.SiteGuid })); } return(RedirectToAction("LoginPageInfo")); }
private bool MatchTheUserInfo(LoginInfoViewModel login) { var user = _context.Users.Where(u => u.UserId.Equals(login.UserId)).FirstOrDefault(); if (user == null) { return(false); } return(_hasher.CheckThePasswordInfo(login.UserId, login.Password, user.GUIDSalt, user.RNGSalt, user.PasswordHash)); }
public async Task <ActionResult <LoginViewModel> > GetUsers(LoginInfoViewModel loginInfo) { var info = await _user.CheckLoginSV(loginInfo.userEmail, loginInfo.userPassword).FirstOrDefaultAsync(); if (info == null) { return(NotFound()); } else { return(Ok(info)); } //return await _context.Users.ToListAsync(); }
public IActionResult LoginInformation(LoginInfoViewModel model) { if (TryValidateModel(model)) { var registrationData = new RegistrationViewModel { PersonalInfo = HttpContext.Session.GetObjectFromJson <PersonalInfoViewModel>("PersonalInfo"), CompanyInfo = HttpContext.Session.GetObjectFromJson <CompanyInfoViewModel>("CompanyInfo"), TrucksInfo = HttpContext.Session.GetObjectFromJson <TrucksInfoViewModel>("TrucksInfo"), LoginInfo = model }; var warriorUser = registrationData.ToWarriorUser(); warriorUser = _userService.CreateUser(warriorUser); return(View("Summary", registrationData)); } return(View(model)); }
public async Task <LoginInfoViewModel> Login(LoginViewModel model) { var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, model.RememberMe, false); if (!result.Succeeded) { throw new UnauthorizedAccessException("Could not login"); } var appUser = _userManager.Users.Single(r => r.UserName == model.Username); var loginResult = new LoginInfoViewModel { UserId = appUser.Id, Token = JwtService.GenerateJwtToken(_configuration, model.Username, appUser), }; return(loginResult); }
public async Task <ActionResult> Login(LoginInfoViewModel loginInfo) { var json = new mJsonResult(); try { if (loginInfo.UserName != "admin") { json.msg = "无法登录!"; return(Json(json)); } var user = await _userService.GetUserFromLogin(loginInfo.UserName, loginInfo.UserPassword); if (user != null) { _authenticationService.SignIn(new UserInfo { UserId = user.ID, UserName = user.UserName }, true); json.success = true; json.msg = "登录成功"; return(Json(json)); } else { json.msg = "用户名或密码错误!"; } } catch (Exception ex) { _logger.Error("登录异常" + ex.Message); json.msg = "登录异常!"; } return(Json(json)); }
// ---------------------------------------------------- // 명시적 인터페이스 구현 // ---------------------------------------------------- bool IUser.MatchTheUserInfo(LoginInfoViewModel login) { return(MatchTheUserInfo(login)); //return checkTheUserInfo(login.UserId, login.Password); }
// Data => Services => Web // Data => Services // Data => Web public async Task <IActionResult> LoginAsync(LoginInfoViewModel login, string returnUrl) { ViewData["ReturnUrl"] = returnUrl; string message = string.Empty; if (ModelState.IsValid) { //string guidSalt = _hasher.GetGUIDSalt(); //string rngSalt = _hasher.GetRNGSalt(); //string passwordHash = _hasher.GetPasswordHash(login.UserId, login.Password, guidSalt, rngSalt); //if (login.UserId.Equals(userId) && login.Password.Equals(password)) if (_user.MatchTheUserInfo(login)) { // 신원보증과 승인권한 var userInfo = _user.GetUserInfo(login.UserId); var roles = _user.GetRolesOwnedByUser(login.UserId); var userTopRole = roles.FirstOrDefault(); string userDataInfo = userTopRole.UserRole.RoleName + "|" + userTopRole.UserRole.RolePriority.ToString() + "|" + userInfo.UserName + "|" + userInfo.UserEmail; var identity = new ClaimsIdentity(claims: new[] { new Claim(type: ClaimTypes.Name, value: userInfo.UserId), new Claim(type: ClaimTypes.Role, value: userTopRole.RoleId), new Claim(type: ClaimTypes.UserData, value: userDataInfo) }, authenticationType: CookieAuthenticationDefaults.AuthenticationScheme); await _context.SignInAsync(scheme : CookieAuthenticationDefaults.AuthenticationScheme, principal : new ClaimsPrincipal(identity), properties : new AuthenticationProperties() { IsPersistent = login.RememberMe, ExpiresUtc = login.RememberMe ? DateTime.UtcNow.AddDays(7) : DateTime.UtcNow.AddMinutes(30) }); TempData["Message"] = "로그인이 성공적으로 이루어졌습니다."; //return RedirectToAction("Index", "Membership"); return(RedirectToLocal(returnUrl)); } else { message = "로그인되지 않았습니다."; } } else { message = "로그인 정보를 올바르게 입력하세요!!"; } ModelState.AddModelError(string.Empty, message); return(View("Login", login)); }