Merge branch 'master' into net6.0

This commit is contained in:
不做码农
2022-03-27 14:18:34 +08:00
20 changed files with 216 additions and 149 deletions

View File

@@ -86,8 +86,8 @@ namespace ZR.Admin.WebApi.Controllers.System
List<string> permissions = permissionService.GetMenuPermission(user);
LoginUser loginUser = new(user, roles, permissions);
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, loginUser);
return SUCCESS(JwtUtil.GenerateJwtToken(HttpContext.AddClaims(loginUser), jwtSettings.JwtSettings));
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, permissions);
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), jwtSettings.JwtSettings));
}
/// <summary>
@@ -103,11 +103,11 @@ namespace ZR.Admin.WebApi.Controllers.System
// //注销登录的用户相当于ASP.NET中的FormsAuthentication.SignOut
// await HttpContext.SignOutAsync();
//}).Wait();
var id = HttpContext.GetUId();
var userid = HttpContext.GetUId();
var name = HttpContext.GetName();
CacheHelper.Remove(GlobalConstant.UserPermKEY + id);
return SUCCESS(new { name , id});
CacheHelper.Remove(GlobalConstant.UserPermKEY + userid);
return SUCCESS(new { name , id = userid });
}
/// <summary>

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
@@ -94,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
return ToResponse(ApiResult.Error($"新增用户 '{user.UserName}'失败,登录账号已存在"));
}
user.Create_by = User.Identity.Name;
user.Create_by = HttpContext.GetName();
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
return ToResponse(UserService.InsertUser(user));
@@ -112,7 +113,7 @@ namespace ZR.Admin.WebApi.Controllers.System
{
if (user == null || user.UserId <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
user.Update_by = User.Identity.Name;
user.Update_by = HttpContext.GetName();
int upResult = UserService.UpdateUser(user);
return ToResponse(upResult);