public Response <UserView> Get(string id) { var result = new Response <UserView> (); try { result.Result = _app.Get(id); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return(result); }
private User GetUserById(string id) { User user; if (id == Define.SYSTEM_USERNAME) { user = new User { Account = Define.SYSTEM_USERNAME, Id = Define.SYSTEM_USERNAME, Name = Define.SYSTEM_USERNAME }; } else { user = UserManager.Get(id); } return(user); }
public LoginResult Parse(PassportLoginRequest model) { var result = new LoginResult(); try { model.Trim(); //获取应用信息 var appInfo = _appInfoService.Get(model.AppKey); if (appInfo == null) { throw new Exception("应用不存在"); } //获取用户信息 User userInfo = null; if (model.Account == "System") { userInfo = new User { Id = Guid.Empty.ToString(), //TODO:可以根据需要调整 Account = "System", Name = "超级管理员", Password = "******" }; } else { //todo:get user userInfo = _userManager.Get(model.Account); } if (userInfo == null) { throw new Exception("用户不存在"); } if (userInfo.Password != model.Password) { throw new Exception("密码错误"); } var currentSession = new UserAuthSession { Account = model.Account, Name = userInfo.Name, Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"), AppKey = model.AppKey, CreateTime = DateTime.Now // , IpAddress = HttpContext.Current.Request.UserHostAddress }; //创建Session _objCacheProvider.Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10)); result.Code = 200; result.ReturnUrl = appInfo.ReturnUrl; result.Token = currentSession.Token; } catch (Exception ex) { result.Code = 500; result.Message = ex.Message; } return(result); }