diff --git a/src/X1.Infrastructure/Services/UserManagement/UserRegistrationService.cs b/src/X1.Infrastructure/Services/UserManagement/UserRegistrationService.cs index e7bea13..c01331b 100644 --- a/src/X1.Infrastructure/Services/UserManagement/UserRegistrationService.cs +++ b/src/X1.Infrastructure/Services/UserManagement/UserRegistrationService.cs @@ -23,7 +23,7 @@ public class UserRegistrationService : IUserRegistrationService private readonly ILogger _logger; private readonly IDistributedLockService _lockService; private readonly IUserRoleRepository _userRoleRepository; - + private const string Description = "超级管理员"; public UserRegistrationService( UserManager userManager, RoleManager roleManager, @@ -108,13 +108,13 @@ public class UserRegistrationService : IUserRegistrationService // 检查是否是第一个用户 var isFirstUser = !await _userManager.Users.AnyAsync(); - string roleName = isFirstUser ? "Admin" : "User"; + string roleName = isFirstUser ? "User" : "Admin"; // 获取或创建角色 var role = await _roleManager.FindByNameAsync(roleName); if (role == null) { - role = new AppRole { Name = roleName }; + role = new AppRole { Name = roleName,Description=(isFirstUser?string.Empty: Description) }; var roleResult = await _roleManager.CreateAsync(role); if (!roleResult.Succeeded) { diff --git a/src/X1.Presentation/Controllers/AuthController.cs b/src/X1.Presentation/Controllers/AuthController.cs index ce2aca3..631e653 100644 --- a/src/X1.Presentation/Controllers/AuthController.cs +++ b/src/X1.Presentation/Controllers/AuthController.cs @@ -116,7 +116,13 @@ public class AuthController : ApiController _cache.Remove(cacheKey); _logger.LogInformation("账号 {UserName} 登录成功", command.UserName); } - _logger.LogWarning($"Bearer {result.Data.AccessToken}"); + + // 只有在登录成功时才记录访问令牌 + if (result.IsSuccess && result.Data?.AccessToken != null) + { + _logger.LogWarning($"Bearer {result.Data.AccessToken}"); + } + return Ok(result); } catch (Exception ex) @@ -188,7 +194,13 @@ public class AuthController : ApiController _cache.Remove(cacheKey); _logger.LogInformation("邮箱 {Email} 登录成功", command.Email); } - _logger.LogWarning($"Bearer {result.Data.AccessToken}"); + + // 只有在登录成功时才记录访问令牌 + if (result.IsSuccess && result.Data?.AccessToken != null) + { + _logger.LogWarning($"Bearer {result.Data.AccessToken}"); + } + return Ok(result); } catch (Exception ex) diff --git a/src/X1.WebUI/src/constants/auth.ts b/src/X1.WebUI/src/constants/auth.ts index 41bb517..dca177f 100644 --- a/src/X1.WebUI/src/constants/auth.ts +++ b/src/X1.WebUI/src/constants/auth.ts @@ -47,5 +47,5 @@ export const AUTH_CONSTANTS = { export const DEFAULT_CREDENTIALS = { username: 'hyh', - password: 'Hyh@123456' + password: 'H295172551@qq.com' }; \ No newline at end of file diff --git a/src/X1.WebUI/src/pages/roles/RoleTable.tsx b/src/X1.WebUI/src/pages/roles/RoleTable.tsx index 68277a9..e0cd277 100644 --- a/src/X1.WebUI/src/pages/roles/RoleTable.tsx +++ b/src/X1.WebUI/src/pages/roles/RoleTable.tsx @@ -69,7 +69,7 @@ export default function RoleTable({ {visibleColumns.map(col => ( {col.title} @@ -93,10 +93,10 @@ export default function RoleTable({ roles.map((role) => ( {visibleColumns.map(col => { - if (col.key === 'name') return {role.name}; - if (col.key === 'description') return {role.description}; - if (col.key === 'createdAt') return {formatToBeijingTime(role.createdAt)}; - if (col.key === 'updatedAt') return {formatToBeijingTime(role.updatedAt)}; + if (col.key === 'name') return {role.name}; + if (col.key === 'description') return {role.description}; + if (col.key === 'createdAt') return {formatToBeijingTime(role.createdAt)}; + if (col.key === 'updatedAt') return {formatToBeijingTime(role.updatedAt)}; if (col.key === 'actions') return (