From 58bbb2b9670ba18a8c4d8218297ca2ab19002905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Sat, 8 Jan 2022 21:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/Filters/VerifyAttribute.cs | 2 +- ZR.Admin.WebApi/Framework/JwtUtil.cs | 10 ++++++--- ZR.CodeGenerator/CodeGenerateTemplate.cs | 2 +- ZR.Service/System/SysUserService.cs | 1 + ZR.Vue/src/views/tool/file/index.vue | 26 ++++++++-------------- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ZR.Admin.WebApi/Filters/VerifyAttribute.cs b/ZR.Admin.WebApi/Filters/VerifyAttribute.cs index 2b4db73..8051b80 100644 --- a/ZR.Admin.WebApi/Filters/VerifyAttribute.cs +++ b/ZR.Admin.WebApi/Filters/VerifyAttribute.cs @@ -22,7 +22,7 @@ namespace ZR.Admin.WebApi.Filters public class VerifyAttribute : Attribute, IAuthorizationFilter { static readonly Logger logger = LogManager.GetCurrentClassLogger(); - IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); + //IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment)); //public VerifyAttribute() { } diff --git a/ZR.Admin.WebApi/Framework/JwtUtil.cs b/ZR.Admin.WebApi/Framework/JwtUtil.cs index 9708e4c..4a438ec 100644 --- a/ZR.Admin.WebApi/Framework/JwtUtil.cs +++ b/ZR.Admin.WebApi/Framework/JwtUtil.cs @@ -1,4 +1,5 @@ using Infrastructure; +using Infrastructure.Extensions; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; @@ -74,7 +75,10 @@ namespace ZR.Admin.WebApi.Framework { JwtSettings jwtSettings = new(); ConfigUtils.Instance.Bind("JwtSettings", jwtSettings); - + if (jwtSettings == null || jwtSettings.SecretKey.IsEmpty()) + { + return null; + } var key = Encoding.ASCII.GetBytes(jwtSettings.SecretKey); var tokenDescriptor = new TokenValidationParameters @@ -125,8 +129,8 @@ namespace ZR.Admin.WebApi.Framework { try { - var userId = jwtToken.FirstOrDefault(x => x.Type == "primarysid").Value; - var userName = jwtToken.FirstOrDefault(x => x.Type == "unique_name").Value; + //var userId = jwtToken.FirstOrDefault(x => x.Type == "primarysid").Value; + //var userName = jwtToken.FirstOrDefault(x => x.Type == "unique_name").Value; var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData).Value; LoginUser loginUser = JsonConvert.DeserializeObject(userData); diff --git a/ZR.CodeGenerator/CodeGenerateTemplate.cs b/ZR.CodeGenerator/CodeGenerateTemplate.cs index b3bb091..c3fc6af 100644 --- a/ZR.CodeGenerator/CodeGenerateTemplate.cs +++ b/ZR.CodeGenerator/CodeGenerateTemplate.cs @@ -80,7 +80,7 @@ namespace ZR.CodeGenerator //时间 sb.AppendLine(" "); sb.AppendLine($" "); - sb.AppendLine($" "); + sb.AppendLine($" "); sb.AppendLine(" "); sb.AppendLine(" "); } diff --git a/ZR.Service/System/SysUserService.cs b/ZR.Service/System/SysUserService.cs index e856c61..fa58abe 100644 --- a/ZR.Service/System/SysUserService.cs +++ b/ZR.Service/System/SysUserService.cs @@ -55,6 +55,7 @@ namespace ZR.Service if (user != null && user.UserId > 0) { user.Roles = RoleService.SelectUserRoleListByUserId(userId); + user.RoleIds = user.Roles.Select(x => x.RoleId).ToArray(); } return user; } diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue index 2faffb7..8e98752 100644 --- a/ZR.Vue/src/views/tool/file/index.vue +++ b/ZR.Vue/src/views/tool/file/index.vue @@ -3,7 +3,8 @@ - + @@ -35,7 +36,8 @@ \ No newline at end of file