public async Task <IActionResult> Loign(string userName, string password, string returnUrl = null) { ViewData["returnUrl"] = returnUrl; UserInfoLoginInput model = new UserInfoLoginInput { LoginName = userName, Password = password }; var user = await iUserInfoService.GetModelByLogin(model); if (user != null) { AuthenticationProperties props = new AuthenticationProperties() { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(1)) }; await HttpContext.SignInAsync(user.Id.ToString(), user.UserName, props); if (returnUrl != null) { return(Redirect(returnUrl)); } return(View()); } else { return(View()); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <UserInfoLoginOut> GetModelByLogin(UserInfoLoginInput model) { DynamicParameters dparams = new DynamicParameters(); dparams.Add("LoginName", model.LoginName, System.Data.DbType.String, System.Data.ParameterDirection.Input); dparams.Add("Password", model.Password, System.Data.DbType.String, System.Data.ParameterDirection.Input); return(await _context._connection.QueryFirstOrDefault(DDD.Infrastructure.SqlMaps.UserSql.UserInfoLogin(model.LoginName, model.Password), dparams)); }
/// <summary> /// 用户登录 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <UserInfoLoginOut> GetModelByLogin(UserInfoLoginInput model) { var userInfo = await iUserInfoRepository.GetModelByLogin(model); return(userInfo); }