/// <summary> /// Saas后台管理登录 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public async Task <(string Error, User User)> SaasLoginAsync(string account, string password, string ip = "") { User user = await UserRep.FindSingleAsync(o => o.Account == account); if (user == null) { return($"帐号不存在", null); } if (user.State == 0) { return($"帐号禁止登录", null); } if (user.Password != password) { return($"密码不正确", null); } CurrentUser curUser = new CurrentUser { Id = user.Id, RealName = user.Account, LoginIPAddress = ip }; await OperateLogApp.CustomLogAsync(curUser, "用户登录", user.RealName + "进行了登录操作"); await UserRep.UpdateAsync(o => o.Id == user.Id, o => new User() { LastLoginTime = DateTime.Now }); return(string.Empty, user); }
/// <summary> /// 用户退出操作 /// </summary> /// <param name="curUser">登录用户信息</param> /// <returns></returns> public async Task LogOffAsync(CurrentUser curUser) { await OperateLogApp.CustomLogAsync(curUser, "用户退出", curUser.RealName + "进行了退出操作"); }